pywin32-checkins Mailing List for Python for Windows Extensions (Page 28)
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: Mark H. <mha...@us...> - 2009-01-08 12:28:50
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18300/Pythonwin/pywin/framework Modified Files: scriptutils.py Log Message: py3k-friendly reload Index: scriptutils.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/scriptutils.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** scriptutils.py 3 Jan 2009 05:43:19 -0000 1.22 --- scriptutils.py 8 Jan 2009 12:28:42 -0000 1.23 *************** *** 413,419 **** exec codeObj in __main__.__dict__ if bNeedReload: reload(sys.modules[modName]) - # codeObj = compile('reload('+modName+')','<auto import>','eval') - # exec codeObj in __main__.__dict__ win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"'") except: --- 413,421 ---- exec codeObj in __main__.__dict__ if bNeedReload: + try: + from imp import reload # py3k + except ImportError: + pass # reload a builtin in py2k reload(sys.modules[modName]) win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"'") except: |
From: Mark H. <mha...@us...> - 2009-01-08 04:22:16
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5944/com/win32com/test Modified Files: testall.py Log Message: hook the directsound tests into the main test suite Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** testall.py 26 Nov 2008 08:52:32 -0000 1.31 --- testall.py 8 Jan 2009 04:22:04 -0000 1.32 *************** *** 82,85 **** --- 82,87 ---- ExecuteSilentlyIfOK(cmd, self) + # This is a list of "win32com.test.???" module names, optionally with a + # function in that module if the module isn't unitest based... unittest_modules = [ # Level 1 tests. *************** *** 99,102 **** --- 101,117 ---- ] + # A list of other unittest modules we use - these are fully qualified module + # names and the module is assumed to be unittest based. + unittest_other_modules = [ + # Level 1 tests. + """win32com.directsound.test.ds_test + """.split(), + # Level 2 tests. + [], + # Level 3 tests. + [] + ] + + output_checked_programs = [ # Level 1 tests. *************** *** 171,174 **** --- 186,206 ---- for test_class in custom_test_cases[i]: suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(test_class)) + # other "normal" unittest modules. + for i in range(testLevel): + for mod_name in unittest_other_modules[i]: + try: + __import__(mod_name) + except: + import_failures.append((mod_name, sys.exc_info()[:2])) + continue + + mod = sys.modules[mod_name] + if hasattr(mod, "suite"): + test = mod.suite() + else: + test = loader.loadTestsFromModule(mod) + assert test.countTestCases() > 0, "No tests loaded from %r" % mod + suite.addTest(test) + return suite, import_failures |
From: Mark H. <mha...@us...> - 2009-01-08 04:22:10
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5944 Modified Files: setup.py Log Message: hook the directsound tests into the main test suite Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** setup.py 7 Jan 2009 04:11:06 -0000 1.89 --- setup.py 8 Jan 2009 04:22:04 -0000 1.90 *************** *** 1822,1825 **** --- 1822,1826 ---- 'win32comext.taskscheduler', 'win32comext.directsound', + 'win32comext.directsound.test', 'win32comext.authorization', 'win32comext.bits', |
From: Mark H. <mha...@us...> - 2009-01-08 04:22:10
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5944/com/win32comext/directsound/test Modified Files: ds_test.py Added Files: __init__.py Log Message: hook the directsound tests into the main test suite Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ds_test.py 8 Jan 2009 03:51:47 -0000 1.7 --- ds_test.py 8 Jan 2009 04:22:04 -0000 1.8 *************** *** 6,10 **** import win32event, win32api import os ! from pywin32_testutil import str2bytes import win32com.directsound.directsound as ds # next two lines are for for debugging: --- 6,10 ---- import win32event, win32api import os ! from pywin32_testutil import str2bytes, TestSkipped import win32com.directsound.directsound as ds # next two lines are for for debugging: *************** *** 263,267 **** def testPlay(self): '''Mesdames et Messieurs, la cour de Devin Dazzle''' ! fname=os.path.join(os.path.dirname(__file__), "01-Intro.wav") f = open(fname, 'rb') hdr = f.read(WAV_HEADER_SIZE) --- 263,282 ---- def testPlay(self): '''Mesdames et Messieurs, la cour de Devin Dazzle''' ! # look for the test file in various places ! candidates = [ ! os.path.dirname(__file__), ! os.path.dirname(sys.argv[0]), ! # relative to 'testall.py' in the win32com test suite. ! os.path.join(os.path.dirname(sys.argv[0]), ! '../../win32comext/directsound/test'), ! '.', ! ] ! for candidate in candidates: ! fname=os.path.join(candidate, "01-Intro.wav") ! if os.path.isfile(fname): ! break ! else: ! raise TestSkipped("Can't find test .wav file to play") ! f = open(fname, 'rb') hdr = f.read(WAV_HEADER_SIZE) --- NEW FILE: __init__.py --- # This is a Python package, imported by the win32com test suite. |
From: Mark H. <mha...@us...> - 2009-01-08 03:52:01
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4344/com/win32comext/directsound/test Modified Files: ds_test.py Log Message: py3k-friendly handling of bytes Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ds_test.py 26 Nov 2008 08:52:32 -0000 1.6 --- ds_test.py 8 Jan 2009 03:51:47 -0000 1.7 *************** *** 6,9 **** --- 6,10 ---- import win32event, win32api import os + from pywin32_testutil import str2bytes import win32com.directsound.directsound as ds # next two lines are for for debugging: *************** *** 19,26 **** = struct.unpack('<4sl4s4slhhllhh4sl', data) ! if riff != 'RIFF': raise ValueError('invalid wav header') ! if fmtsize != 16 or fmt != 'fmt ' or data != 'data': # fmt chuck is not first chunk, directly followed by data chuck # It is nowhere required that they are, it is just very common --- 20,27 ---- = struct.unpack('<4sl4s4slhhllhh4sl', data) ! if riff != str2bytes('RIFF'): raise ValueError('invalid wav header') ! if fmtsize != 16 or fmt != str2bytes('fmt ') or str2bytes(data) != 'data': # fmt chuck is not first chunk, directly followed by data chuck # It is nowhere required that they are, it is just very common |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:59
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/win32/test Modified Files: Tag: py3k test_pywintypes.py test_win32file.py Log Message: merge various changes, particularly PyTime, from trunk Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.13.2.5 retrieving revision 1.13.2.6 diff -C2 -d -r1.13.2.5 -r1.13.2.6 *** test_win32file.py 7 Jan 2009 06:25:16 -0000 1.13.2.5 --- test_win32file.py 8 Jan 2009 03:45:50 -0000 1.13.2.6 *************** *** 10,13 **** --- 10,19 ---- import shutil import socket + import datetime + + try: + set + except NameError: + from sets import Set as set class TestSimpleOps(unittest.TestCase): *************** *** 116,119 **** --- 122,168 ---- os.unlink(filename) + def testFileTimes(self): + if issubclass(pywintypes.TimeType, datetime.datetime): + from win32timezone import GetLocalTimeZone + now = datetime.datetime.now(tz=GetLocalTimeZone()) + ok_delta = datetime.timedelta(seconds=1) + later = now + datetime.timedelta(seconds=120) + else: + tick = int(time.time()) + now = pywintypes.Time(tick) + ok_delta = 1 + later = pywintypes.Time(tick+120) + + filename = tempfile.mktemp("-testFileTimes") + # Windows docs the 'last time' isn't valid until the last write + # handle is closed - so create the file, then re-open it to check. + open(filename,"w").close() + f = win32file.CreateFile(filename, win32file.GENERIC_READ|win32file.GENERIC_WRITE, + 0, None, + win32con.OPEN_EXISTING, 0, None) + # *sob* - before we had tz aware datetime objects, we are faced + # with FILETIME objects being +GST out from now(). So just skip + # this... + if not issubclass(pywintypes.TimeType, datetime.datetime): + return + try: + ct, at, wt = win32file.GetFileTime(f) + self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) + self.failUnless( now <= ct <= now + ok_delta, (now, ct)) + self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) + self.failUnless( now <= wt <= now + ok_delta, (now, wt)) + + # Now set the times. + win32file.SetFileTime(f, later, later, later) + # Get them back. + ct, at, wt = win32file.GetFileTime(f) + self.failUnlessEqual(ct, later) + self.failUnlessEqual(at, later) + self.failUnlessEqual(wt, later) + + finally: + f.Close() + os.unlink(filename) + class TestOverlapped(unittest.TestCase): def testSimpleOverlapped(self): *************** *** 198,204 **** # reference counting should catch that error. overlapped = None ! self.failUnlessRaises(RuntimeError, ! win32file.GetQueuedCompletionStatus, port, -1) ! handle.Close() return --- 247,257 ---- # reference counting should catch that error. overlapped = None ! # even if we fail, be sure to close the handle; prevents hangs ! # on Vista 64... ! try: ! self.failUnlessRaises(RuntimeError, ! win32file.GetQueuedCompletionStatus, port, -1) ! finally: ! handle.Close() return *************** *** 231,235 **** t = threading.Thread(target=self._IOCPServerThread, args=(handle,port, test_overlapped_death)) - # hrmph - markh is seeing failures here on x64 - and a hang! t.setDaemon(True) # avoid hanging entire test suite on failure. t.start() --- 284,287 ---- Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.3.4.3 retrieving revision 1.3.4.4 diff -C2 -d -r1.3.4.3 -r1.3.4.4 *** test_pywintypes.py 7 Jan 2009 06:25:16 -0000 1.3.4.3 --- test_pywintypes.py 8 Jan 2009 03:45:50 -0000 1.3.4.4 *************** *** 3,6 **** --- 3,7 ---- import time from pywin32_testutil import str2bytes, ob2memory + import datetime class TestCase(unittest.TestCase): *************** *** 9,14 **** pytime_current = pywintypes.Time(struct_current) # try and test all the standard parts of the format ! format_string = "%a %A %b %B %c %d %H %I %j %m %M %p %S %U %w %W %x %X %y %Y %Z" ! self.assertEquals(pytime_current.Format(format_string), time.strftime(format_string, struct_current)) def testPyTimePrint(self): --- 10,18 ---- 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) ! v2 = time.strftime(fmt, struct_current) ! self.assertEquals(v1, v2, "format %s failed - %r != %r" % (fmt, v1, v2)) def testPyTimePrint(self): *************** *** 17,26 **** # (as hopefully this wont be true forever). So either working, or # ValueError is OK. - t = pywintypes.Time(-2) try: t.Format() except ValueError: return def testPyTimeCompare(self): t1 = pywintypes.Time(100) --- 21,35 ---- # (as hopefully this wont be true forever). So either working, or # ValueError is OK. try: + t = pywintypes.Time(-2) t.Format() except ValueError: return + def testTimeInDict(self): + d = {} + d['t1'] = pywintypes.Time(1) + self.failUnlessEqual(d['t1'], pywintypes.Time(1)) + def testPyTimeCompare(self): t1 = pywintypes.Time(100) *************** *** 36,39 **** --- 45,68 ---- self.failUnless(t2 > t1 ) + def testTimeTuple(self): + now = datetime.datetime.now() # has usec... + # timetuple() lost usec - pt must be <=... + pt = pywintypes.Time(now.timetuple()) + # *sob* - only if we have a datetime object can we compare like this. + if isinstance(pt, datetime.datetime): + self.failUnless(pt <= now) + + def testTimeTuplems(self): + now = datetime.datetime.now() # has usec... + tt = now.timetuple() + (now.microsecond // 1000,) + pt = pywintypes.Time(tt) + # we can't compare if using the old type, as it loses all sub-second res. + if isinstance(pt, datetime.datetime): + self.failUnlessEqual(now, pt) + + def testPyTimeFromTime(self): + t1 = pywintypes.Time(time.time()) + self.failUnless(pywintypes.Time(t1) is t1) + def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:57
|
Update of /cvsroot/pywin32/pywin32/com/win32com/servers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/com/win32com/servers Modified Files: Tag: py3k PythonTools.py Log Message: merge various changes, particularly PyTime, from trunk Index: PythonTools.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/servers/PythonTools.py,v retrieving revision 1.3.4.5 retrieving revision 1.3.4.6 diff -C2 -d -r1.3.4.5 -r1.3.4.6 *** PythonTools.py 5 Jan 2009 12:51:26 -0000 1.3.4.5 --- PythonTools.py 8 Jan 2009 03:45:49 -0000 1.3.4.6 *************** *** 6,16 **** def reload(self, module): - # XXX - need py3k work for 'reload' if module in sys.modules: try: from imp import reload except ImportError: ! # builtin in py3k ! pass reload(sys.modules[module]) return "reload succeeded." --- 6,14 ---- def reload(self, module): if module in sys.modules: try: from imp import reload except ImportError: ! pass # builtin in py2k reload(sys.modules[module]) return "reload succeeded." |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:56
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/com/win32comext/adsi/src Modified Files: Tag: py3k PyADSIUtil.cpp Log Message: merge various changes, particularly PyTime, from trunk Index: PyADSIUtil.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/src/PyADSIUtil.cpp,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -C2 -d -r1.6 -r1.6.4.1 *** PyADSIUtil.cpp 4 Aug 2006 08:33:44 -0000 1.6 --- PyADSIUtil.cpp 8 Jan 2009 03:45:50 -0000 1.6.4.1 *************** *** 212,216 **** else if (PyInt_Check(val)) dwType = ADSTYPE_INTEGER; ! else if (PyTime_Check(val)) dwType = ADSTYPE_UTC_TIME; else { --- 212,216 ---- else if (PyInt_Check(val)) dwType = ADSTYPE_INTEGER; ! else if (PyWinTime_Check(val)) dwType = ADSTYPE_UTC_TIME; else { |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:55
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/com/win32com/src Modified Files: Tag: py3k PyComHelpers.cpp PythonCOM.cpp oleargs.cpp Log Message: merge various changes, particularly PyTime, from trunk Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.52.2.4 retrieving revision 1.52.2.5 diff -C2 -d -r1.52.2.4 -r1.52.2.5 *** PythonCOM.cpp 19 Dec 2008 02:33:56 -0000 1.52.2.4 --- PythonCOM.cpp 8 Jan 2009 03:45:49 -0000 1.52.2.5 *************** *** 742,758 **** } - // @pymethod <o PyIID>|pythoncom|MakeIID|Creates a new IID object. static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! // @comm This is simply an alias for <om pywintypes.IID>. Please see that method ! // for details. return PyWinMethod_NewIID(self, args); } ! // @pymethod <o PyTime>|pythoncom|MakeTime|Creates a new time object. static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! // @comm This is simply an alias for <om pywintypes.Time>. Please see that method ! // for details. return PyWinMethod_NewTime(self, args); } --- 742,755 ---- } static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeIID is deprecated - please use pywintypes.IID() instead.", 1); return PyWinMethod_NewIID(self, args); } ! // no autoduct - this is deprecated. static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeTime is deprecated - please use pywintypes.Time() instead.", 1); return PyWinMethod_NewTime(self, args); } *************** *** 1898,1903 **** { "LoadRegTypeLib", pythoncom_loadregtypelib, 1 }, // @pymeth LoadRegTypeLib|Loads a registered type library by CLSID { "LoadTypeLib", pythoncom_loadtypelib, 1 }, // @pymeth LoadTypeLib|Loads a type library by name ! { "MakeIID", pythoncom_MakeIID, 1 }, // @pymeth MakeIID|Makes an IID object from a string. ! { "MakeTime", pythoncom_MakeTime, 1 }, // @pymeth MakeTime|Makes a time object from the argument. Argument can be an integer/float or a tuple (as returned by time module functions). { "MakePyFactory", pythoncom_MakePyFactory, 1 }, // @pymeth MakePyFactory|Creates a new <o PyIClassFactory> object wrapping a PythonCOM Class Factory object. #ifndef MS_WINCE --- 1895,1900 ---- { "LoadRegTypeLib", pythoncom_loadregtypelib, 1 }, // @pymeth LoadRegTypeLib|Loads a registered type library by CLSID { "LoadTypeLib", pythoncom_loadtypelib, 1 }, // @pymeth LoadTypeLib|Loads a type library by name ! { "MakeIID", pythoncom_MakeIID, 1 }, ! { "MakeTime", pythoncom_MakeTime, 1 }, { "MakePyFactory", pythoncom_MakePyFactory, 1 }, // @pymeth MakePyFactory|Creates a new <o PyIClassFactory> object wrapping a PythonCOM Class Factory object. #ifndef MS_WINCE Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.15.2.3 retrieving revision 1.15.2.4 diff -C2 -d -r1.15.2.3 -r1.15.2.4 *** PyComHelpers.cpp 11 Oct 2008 18:44:57 -0000 1.15.2.3 --- PyComHelpers.cpp 8 Jan 2009 03:45:49 -0000 1.15.2.4 *************** *** 330,342 **** if (!PyWinObject_AsULARGE_INTEGER(obSize, &pStat->cbSize)) return FALSE; ! if (!PyTime_Check(obmtime) || !PyTime_Check(obctime) || !PyTime_Check(obatime)) { PyErr_SetString(PyExc_TypeError, "The time entries in a STATSTG tuple must be PyTime objects"); return FALSE; } ! if (!((PyTime *)obmtime)->GetTime(&pStat->mtime)) return FALSE; ! if (!((PyTime *)obctime)->GetTime(&pStat->ctime)) return FALSE; ! if (!((PyTime *)obatime)->GetTime(&pStat->atime)) return FALSE; if (!PyWinObject_AsIID(obCLSID, &pStat->clsid)) --- 330,342 ---- if (!PyWinObject_AsULARGE_INTEGER(obSize, &pStat->cbSize)) return FALSE; ! if (!PyWinTime_Check(obmtime) || !PyWinTime_Check(obctime) || !PyWinTime_Check(obatime)) { PyErr_SetString(PyExc_TypeError, "The time entries in a STATSTG tuple must be PyTime objects"); return FALSE; } ! if (!PyWinObject_AsFILETIME(obmtime, &pStat->mtime)) return FALSE; ! if (!PyWinObject_AsFILETIME(obctime, &pStat->ctime)) return FALSE; ! if (!PyWinObject_AsFILETIME(obatime, &pStat->atime)) return FALSE; if (!PyWinObject_AsIID(obCLSID, &pStat->clsid)) Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.41.2.5 retrieving revision 1.41.2.6 diff -C2 -d -r1.41.2.5 -r1.41.2.6 *** oleargs.cpp 13 Oct 2008 20:39:41 -0000 1.41.2.5 --- oleargs.cpp 8 Jan 2009 03:45:49 -0000 1.41.2.6 *************** *** 154,158 **** V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyTime_Check(obj) || PyObject_HasAttrString(obj, "timetuple")) { V_VT(var) = VT_DATE; --- 154,158 ---- V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyWinTime_Check(obj)) { V_VT(var) = VT_DATE; *************** *** 1290,1294 **** V_DATEREF(var) = &m_dateBuf; if (!VALID_BYREF_MISSING(obj)) { ! if ( !PyTime_Check(obj) ) BREAK_FALSE; if ( !PyWinObject_AsDATE(obj, V_DATEREF(var) ) ) BREAK_FALSE; } else --- 1290,1294 ---- V_DATEREF(var) = &m_dateBuf; if (!VALID_BYREF_MISSING(obj)) { ! if ( !PyWinTime_Check(obj) ) BREAK_FALSE; if ( !PyWinObject_AsDATE(obj, V_DATEREF(var) ) ) BREAK_FALSE; } else |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:55
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/com/win32com/client Modified Files: Tag: py3k dynamic.py Log Message: merge various changes, particularly PyTime, from trunk Index: dynamic.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v retrieving revision 1.22.2.8 retrieving revision 1.22.2.9 diff -C2 -d -r1.22.2.8 -r1.22.2.9 *** dynamic.py 12 Dec 2008 01:25:54 -0000 1.22.2.8 --- dynamic.py 8 Jan 2009 03:45:49 -0000 1.22.2.9 *************** *** 204,207 **** --- 204,211 ---- return cmp(self._oleobj_, other) + def __eq__(self, other): + other = getattr(other, "_oleobj_", other) + return self._oleobj_ == other + def __int__(self): return int(self.__call__()) |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:55
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/com/win32com/src/extensions Modified Files: Tag: py3k PyIStorage.cpp Log Message: merge various changes, particularly PyTime, from trunk Index: PyIStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIStorage.cpp,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.3 diff -C2 -d -r1.4.4.2 -r1.4.4.3 *** PyIStorage.cpp 11 Oct 2008 18:45:50 -0000 1.4.4.2 --- PyIStorage.cpp 8 Jan 2009 03:45:50 -0000 1.4.4.3 *************** *** 406,431 **** FILETIME *pmtime=NULL, mtime; if (obpctime!=Py_None) { ! pctime = &ctime; ! if (!PyTime_Check(obpctime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpctime)->GetTime(pctime)) return NULL; } if (obpatime != Py_None) { ! patime = &atime; ! if (!PyTime_Check(obpatime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpatime)->GetTime(patime)) return NULL; } if (obpmtime != Py_None) { ! pmtime = &mtime; ! if (!PyTime_Check(obpmtime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpmtime)->GetTime(pmtime)) return NULL; } BSTR bstrName; --- 406,422 ---- FILETIME *pmtime=NULL, mtime; if (obpctime!=Py_None) { ! if (!PyWinObject_AsFILETIME(obpctime, &ctime)) return NULL; ! pctime = &ctime; } if (obpatime != Py_None) { ! if (!PyWinObject_AsFILETIME(obpatime, &atime)) return NULL; ! patime = &atime; } if (obpmtime != Py_None) { ! if (!PyWinObject_AsFILETIME(obpmtime, &mtime)) return NULL; ! pmtime = &mtime; } BSTR bstrName; |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:55
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/win32/Lib Modified Files: Tag: py3k win32timezone.py Log Message: merge various changes, particularly PyTime, from trunk Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.9.2.8 retrieving revision 1.9.2.9 diff -C2 -d -r1.9.2.8 -r1.9.2.9 *** win32timezone.py 3 Jan 2009 04:49:36 -0000 1.9.2.8 --- win32timezone.py 8 Jan 2009 03:45:50 -0000 1.9.2.9 *************** *** 471,478 **** """It may be a bug in Vista, but in standard Windows Vista install (both 32-bit and 64-bit), it appears the TimeZoneKeyName returns a ! string with extraneous characters.""" # remove anything after and including the first null character. ! value, garbage = name.split('\x00',1) ! return value def GetTZCapabilities(): --- 471,482 ---- """It may be a bug in Vista, but in standard Windows Vista install (both 32-bit and 64-bit), it appears the TimeZoneKeyName returns a ! string with extraneous characters. ! >>> __TimeZoneKeyNameWorkaround("foo\\0xxx") ! 'foo' ! >>> __TimeZoneKeyNameWorkaround("foo") ! 'foo' ! """ # remove anything after and including the first null character. ! return name.split('\x00',1)[0] def GetTZCapabilities(): |
From: Mark H. <mha...@us...> - 2009-01-08 03:45:55
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3985/win32/src Modified Files: Tag: py3k PyTime.cpp PyWinTypes.h PyWinTypesmodule.cpp odbc.cpp Log Message: merge various changes, particularly PyTime, from trunk Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.13 retrieving revision 1.20.2.14 diff -C2 -d -r1.20.2.13 -r1.20.2.14 *** odbc.cpp 8 Dec 2008 13:41:06 -0000 1.20.2.13 --- odbc.cpp 8 Jan 2009 03:45:50 -0000 1.20.2.14 *************** *** 885,889 **** ZeroMemory(dt, len); // Accept either a PyTime or datetime object ! if (PyTime_Check(item)){ SYSTEMTIME st; if (!((PyTime *)item)->GetTime(&st)) --- 885,890 ---- ZeroMemory(dt, len); // Accept either a PyTime or datetime object ! #ifndef NO_PYWINTYPES_TIME ! if (PyWinTime_CHECK(item)){ SYSTEMTIME st; if (!((PyTime *)item)->GetTime(&st)) *************** *** 899,902 **** --- 900,904 ---- } else{ + #endif // NO_PYWINTYPES_TIME // Python 2.3 doesn't have C Api for datetime TmpPyObject timeseq = PyObject_CallMethod(item, "timetuple", NULL); *************** *** 929,934 **** // Convert to nanoseconds dt->fraction *= 1000; - } } if (unsuccessful(SQLBindParameter( --- 931,938 ---- // Convert to nanoseconds dt->fraction *= 1000; } + #ifndef NO_PYWINTYPES_TIME + } + #endif // NO_PYWINTYPES_TIME if (unsuccessful(SQLBindParameter( *************** *** 1162,1166 **** rv = ibindFloat(cur, iCol, item); } ! else if (PyTime_Check(item) || PyObject_HasAttrString(item, "timetuple")) { rv = ibindDate(cur, iCol, item); --- 1166,1170 ---- rv = ibindFloat(cur, iCol, item); } ! else if (PyWinTime_Check(item)) { rv = ibindDate(cur, iCol, item); Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.39.2.11 retrieving revision 1.39.2.12 diff -C2 -d -r1.39.2.11 -r1.39.2.12 *** PyWinTypesmodule.cpp 8 Dec 2008 13:41:06 -0000 1.39.2.11 --- PyWinTypesmodule.cpp 8 Jan 2009 03:45:50 -0000 1.39.2.12 *************** *** 23,26 **** --- 23,29 ---- extern PyObject *PyWinMethod_NewHKEY(PyObject *self, PyObject *args); + extern BOOL _PyWinDateTime_Init(); + extern BOOL _PyWinDateTime_PrepareModuleDict(PyObject *dict); + #ifdef MS_WINCE // Where is this supposed to come from on CE??? *************** *** 812,818 **** {"IID", PyWinMethod_NewIID, 1 }, // @pymeth IID|Makes an <o PyIID> object from a string. #endif ! #ifndef NO_PYWINTYPES_TIME ! {"Time", PyWinMethod_NewTime, 1 }, // @pymeth Time|Makes a <o PyTime> object from the argument. Argument can be an integer/float or a tuple (as returned by time module functions). ! #endif #ifndef MS_WINCE {"CreateGuid", PyWin_CreateGuid, 1 }, // @pymeth CreateGuid|Creates a new, unique GUIID. --- 815,819 ---- {"IID", PyWinMethod_NewIID, 1 }, // @pymeth IID|Makes an <o PyIID> object from a string. #endif ! {"Time", PyWinMethod_NewTime, 1 }, // @pymeth Time|Makes a <o PyTime> object from the argument. #ifndef MS_WINCE {"CreateGuid", PyWin_CreateGuid, 1 }, // @pymeth CreateGuid|Creates a new, unique GUIID. *************** *** 1019,1025 **** PYWIN_MODULE_INIT_RETURN_ERROR; ! #ifndef NO_PYWINTYPES_TIME ! ADD_TYPE(TimeType); ! #endif // NO_PYWINTYPES_TIME #ifndef NO_PYWINTYPES_IID ADD_TYPE(IIDType); --- 1020,1025 ---- PYWIN_MODULE_INIT_RETURN_ERROR; ! if (!_PyWinDateTime_PrepareModuleDict(dict)) ! PYWIN_MODULE_INIT_RETURN_ERROR; #ifndef NO_PYWINTYPES_IID ADD_TYPE(IIDType); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.51.2.8 retrieving revision 1.51.2.9 diff -C2 -d -r1.51.2.8 -r1.51.2.9 *** PyWinTypes.h 3 Jan 2009 23:46:35 -0000 1.51.2.8 --- PyWinTypes.h 8 Jan 2009 03:45:50 -0000 1.51.2.9 *************** *** 492,495 **** --- 492,498 ---- ** TIME support */ + // 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); *************** *** 500,523 **** // LARGE_INTEGER prototype to avoid pulling in the windows security headers. PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t); PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate); PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate); ! #ifndef NO_PYWINTYPES_TIME ! extern PYWINTYPES_EXPORT PyTypeObject PyTimeType; // the Type for PyTime ! #define PyTime_Check(ob) ((ob)->ob_type == &PyTimeType) - PYWINTYPES_EXPORT PyObject *PyWinObject_FromDATE(DATE t); - PYWINTYPES_EXPORT PyObject *PyWinTimeObject_FromLong(long t); ! // A global function that can work as a module method for making a time object. ! PYWINTYPES_EXPORT PyObject *PyWinMethod_NewTime( PyObject *self, PyObject *args); ! #endif // NO_PYWINTYPES_TIME ! // Convert a time object to a time_t value. ! PYWINTYPES_EXPORT BOOL PyWinObject_Astime_t(PyObject *ob, time_t *t); // functions to return WIN32_FIND_DATA tuples, used in shell, win32api, and win32file --- 503,525 ---- // LARGE_INTEGER prototype to avoid pulling in the windows security headers. PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t); + PYWINTYPES_EXPORT PyObject *PyWinTimeObject_Fromtime_t(time_t t); + PYWINTYPES_EXPORT PyObject *PyWinObject_FromDATE(DATE t); PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate); PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate); ! // A global function that can work as a module method for making a time object. ! PYWINTYPES_EXPORT PyObject *PyWinMethod_NewTime( PyObject *self, PyObject *args); ! PYWINTYPES_EXPORT BOOL PyWinTime_Check(PyObject *ob); ! #ifndef NO_PYWINTYPES_TIME ! extern PYWINTYPES_EXPORT PyTypeObject PyTimeType; // the Type for PyTime ! #define PyWinTime_CHECK(ob) ((ob)->ob_type == &PyTimeType) ! #endif // NO_PYWINTYPES_TIME // functions to return WIN32_FIND_DATA tuples, used in shell, win32api, and win32file Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.19.2.2 retrieving revision 1.19.2.3 diff -C2 -d -r1.19.2.2 -r1.19.2.3 *** PyTime.cpp 4 Dec 2008 00:07:22 -0000 1.19.2.2 --- PyTime.cpp 8 Jan 2009 03:45:50 -0000 1.19.2.3 *************** *** 5,31 **** #include "PyWinTypes.h" #include "PyWinObjects.h" - #ifndef MS_WINCE #include "time.h" - #endif #include "tchar.h" - #ifndef NO_PYWINTYPES_TIME - - #ifdef MS_WINCE - #include <oleauto.h> // Time conversion functions on CE. - // The Python helpers. - BOOL PyCE_UnixTimeToFileTime(time_t t, LPFILETIME pft); - BOOL PyCE_UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst); - BOOL PyCE_FileTimeToUnixTime(FILETIME *pft, time_t *pt); - BOOL PyCE_SystemTimeToUnixTime(SYSTEMTIME *pst, time_t *pt); - void PyCE_TimeStructToSystemTime(struct tm *ptm, SYSTEMTIME *pst); - #endif - - #if _MSC_VER < 1100 - // MSVC < 5.0 headers dont have these - WINOLEAUTAPI_(INT) SystemTimeToVariantTime(LPSYSTEMTIME lpSystemTime, DOUBLE* pvtime); - WINOLEAUTAPI_(INT) VariantTimeToSystemTime(DOUBLE vtime, LPSYSTEMTIME lpSystemTime); - #endif - static WORD SequenceIndexAsWORD(PyObject *seq, int index) { --- 5,11 ---- *************** *** 36,41 **** --- 16,36 ---- } + BOOL PyWinTime_Check(PyObject *ob) + { + return 0 || + #ifndef NO_PYWINTYPES_TIME + PyWinTime_CHECK(ob) || + #endif + PyObject_HasAttrString(ob, "timetuple"); + } + PyObject *PyWin_NewTime(PyObject *timeOb) { + // If it already a datetime object, just return it as-is. + if (PyWinTime_CHECK(timeOb)) { + Py_INCREF(timeOb); + return timeOb; + } + PyObject *result = NULL; /***** Commented out temporarily *************** *** 129,135 **** return new PyTime(t); } ! PyObject *PyWinTimeObject_FromLong(long t) { ! return new PyTime((time_t)t); } --- 124,130 ---- return new PyTime(t); } ! PyObject *PyWinTimeObject_Fromtime_t(time_t t) { ! return new PyTime(t); } *************** *** 148,152 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 143,147 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 162,166 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 157,161 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 175,179 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 170,174 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 323,331 **** // @xref <om pywintypes.Time> - #endif /* MS_WINCE */ struct PyMethodDef PyTime::methods[] = { - #ifndef MS_WINCE {"Format", PyTime::Format, 1}, // @pymeth Format|Formats the time value - #endif {NULL} }; --- 318,323 ---- *************** *** 424,441 **** ob_type = &PyTimeType; _Py_NewReference(this); - - #ifdef MS_WINCE - /* WinCE makes life harder than it should be! */ - FILETIME ftLocal, ftUTC; - PyCE_UnixTimeToFileTime( (time_t)t, &ftUTC); - FileTimeToLocalFileTime(&ftUTC, &ftLocal); - - time_t temp_t; - - PyCE_FileTimeToUnixTime(&ftLocal, &temp_t); - m_time = (double)temp_t; - - #else - /* "Normal" Win32 handling */ m_time = 0; struct tm *ptm = localtime(&t); --- 416,419 ---- *************** *** 454,458 **** (void)SystemTimeToVariantTime(&st, &m_time); } - #endif /* MS_WINCE */ } --- 432,435 ---- *************** *** 530,534 **** PyObject *PyTime::richcompare(PyObject *other, int op) { ! if (!PyTime_Check(other)){ PyErr_SetString(PyExc_TypeError, "PyTime cannot be compared to other types"); return NULL; --- 507,511 ---- PyObject *PyTime::richcompare(PyObject *other, int op) { ! if (!PyWinTime_Check(other)){ PyErr_SetString(PyExc_TypeError, "PyTime cannot be compared to other types"); return NULL; *************** *** 588,603 **** tm.tm_year = st.wYear - 1900; tm.tm_isdst = -1; /* have the library figure it out */ - - #ifdef MS_WINCE - /* Windows CE hacks! */ - FILETIME ft; - long t; - PyCE_TimeStructToSystemTime(&tm, &st); - SystemTimeToFileTime(&st, &ft); - PyCE_FileTimeToUnixTime(&ft, &t); - - return t; - #else - /* Normal win32 code */ long result = (long)mktime(&tm); if ( result == -1 ) --- 565,568 ---- *************** *** 607,611 **** } return result; - #endif } --- 572,575 ---- *************** *** 782,878 **** } ! #else // NO_PYWINTYPES_TIME ! // We dont have a decent time implementation, but ! // we need _some_ implementation of these functions! ! ! double PyCE_SystemTimeToCTime(SYSTEMTIME* pstTime) ! { ! SYSTEMTIME stBase; ! FILETIME ftTime; ! FILETIME ftBase; ! __int64 iTime; ! __int64 iBase; ! ! SystemTimeToFileTime(pstTime, &ftTime); ! ! stBase.wYear = 1970; ! stBase.wMonth = 1; ! stBase.wDayOfWeek = 1; ! stBase.wDay = 1; ! stBase.wHour = 0; ! stBase.wMinute = 0; ! stBase.wSecond = 0; ! stBase.wMilliseconds = 0; ! SystemTimeToFileTime(&stBase, &ftBase); ! ! iTime=ftTime.dwHighDateTime; ! iTime=iTime << 32; ! iTime |= ftTime.dwLowDateTime; ! ! iBase=ftBase.dwHighDateTime; ! iBase=iBase << 32; ! iBase |= ftBase.dwLowDateTime; ! ! return (double)((iTime - iBase) / 10000000L); ! } ! ! BOOL PyCE_UnixTimeToFileTime(time_t t, LPFILETIME pft) ! { ! // Note that LONGLONG is a 64-bit value ! LONGLONG ll; ! ll = ((__int64)t * 10000000) + 116444736000000000; ! // ll = Int32x32To64(t, 10000000) + 116444736000000000; ! pft->dwLowDateTime = (DWORD)ll; ! pft->dwHighDateTime = (DWORD)(ll >> 32); ! return TRUE; ! } ! ! // We expose some time functions, but just return ! // standard Python floats. We need a better solution! ! ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromSYSTEMTIME(const SYSTEMTIME &st) ! { ! return PyFloat_FromDouble(PyCE_SystemTimeToCTime((SYSTEMTIME *)&st)); ! } ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t) ! { ! SYSTEMTIME st; ! if (!FileTimeToSystemTime(&t, &st)) ! return PyInt_FromLong(-1); ! return PyFloat_FromDouble(PyCE_SystemTimeToCTime(&st)); ! } ! //PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) ! //{ ! //} ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *ft) ! { ! PyObject *intOb = PyNumber_Int(ob); ! if (intOb==NULL) return FALSE; ! time_t t = (time_t)PyInt_AsLong(intOb); ! BOOL rc = PyCE_UnixTimeToFileTime(t, ft); ! Py_DECREF(intOb); ! return rc; ! } ! PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *st) { - FILETIME ft; - if (!PyWinObject_AsFILETIME(ob, &ft)) - return FALSE; - if (!FileTimeToSystemTime(&ft, st)) { - PyErr_SetString(PyExc_TypeError, "The value is out of range for a SYSTEMTIME"); - return FALSE; - } return TRUE; } ! #endif // NO_PYWINTYPES_TIME ! ! PYWINTYPES_EXPORT BOOL PyWinObject_Astime_t(PyObject *ob, time_t *t) { ! // We need to get smarter about 64bit time_t values... ! *t = (time_t)PyInt_AsLong(ob); ! if (*t == -1 && PyErr_Occurred()) return FALSE; return TRUE; } --- 746,764 ---- } ! #endif // NO_PYWINTYPES_TIME ! // A couple of public functions used by the module init ! BOOL _PyWinDateTime_Init() { return TRUE; } ! BOOL _PyWinDateTime_PrepareModuleDict(PyObject *dict) { ! #ifndef NO_PYWINTYPES_TIME ! if (PyType_Ready(&PyTimeType)==-1 ! || PyDict_SetItemString(dict, "TimeType", (PyObject *)&PyTimeType) == -1) return FALSE; + #endif return TRUE; } |
From: Mark H. <mha...@us...> - 2009-01-08 03:44:26
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3895/com/win32com/src Modified Files: Tag: py3k PyRecord.cpp Log Message: merge vc6 compiler fix from trunk Index: PyRecord.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyRecord.cpp,v retrieving revision 1.11.4.4 retrieving revision 1.11.4.5 diff -C2 -d -r1.11.4.4 -r1.11.4.5 *** PyRecord.cpp 19 Dec 2008 02:33:56 -0000 1.11.4.4 --- PyRecord.cpp 8 Jan 2009 03:44:15 -0000 1.11.4.5 *************** *** 465,468 **** --- 465,469 ---- goto done; // must exit on error via loop_error from here... + PyObject *sub_object = NULL; if (i > 0){ PyWinCoreString_Concat(&obrepr, comma); *************** *** 476,480 **** if (!obrepr) goto loop_error; ! PyObject *sub_object = PyRecord::getattro(self, obattrname); if (!sub_object) goto loop_error; --- 477,481 ---- if (!obrepr) goto loop_error; ! sub_object = PyRecord::getattro(self, obattrname); if (!sub_object) goto loop_error; |
From: Mark H. <mha...@us...> - 2009-01-08 03:36:29
|
Update of /cvsroot/pywin32/pywin32/com/win32com/demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3523/com/win32com/demos Modified Files: connect.py Log Message: py3k-friendly checking of bytes and unicode Index: connect.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/connect.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** connect.py 27 Nov 2008 05:40:39 -0000 1.5 --- connect.py 8 Jan 2009 03:36:24 -0000 1.6 *************** *** 10,13 **** --- 10,14 ---- import win32com.server.connect from win32com.server.exception import Exception + from pywin32_testutil import str2bytes # This is the IID of the Events interface both Client and Server support. *************** *** 71,75 **** connection.Connect(server, client, IID_IConnectDemoEvents) CheckEvent(server, client, "Hello", verbose) ! CheckEvent(server, client, "Here is a null>\x00<", verbose) CheckEvent(server, client, u"Here is a null>\x00<", verbose) val = u"test-\xe0\xf2" # 2 extended characters. --- 72,76 ---- connection.Connect(server, client, IID_IConnectDemoEvents) CheckEvent(server, client, "Hello", verbose) ! CheckEvent(server, client, str2bytes("Here is a null>\x00<"), verbose) CheckEvent(server, client, u"Here is a null>\x00<", verbose) val = u"test-\xe0\xf2" # 2 extended characters. |
From: Mark H. <mha...@us...> - 2009-01-08 03:35:46
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3494/win32/test Modified Files: test_win32file.py Log Message: use FailUnlessEqual as it was intended! Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_win32file.py 8 Jan 2009 02:56:18 -0000 1.23 --- test_win32file.py 8 Jan 2009 03:35:41 -0000 1.24 *************** *** 68,73 **** win32file.SetFilePointer(h, newSize, win32file.FILE_BEGIN) win32file.SetEndOfFile(h) ! self.failUnless(win32file.GetFileSize(h) == newSize, ! "Truncated file does not have the expected size! (%s)" %newSize) # GetFileAttributesEx/GetFileAttributesExW tests. --- 68,72 ---- win32file.SetFilePointer(h, newSize, win32file.FILE_BEGIN) win32file.SetEndOfFile(h) ! self.failUnlessEqual(win32file.GetFileSize(h), newSize) # GetFileAttributesEx/GetFileAttributesExW tests. *************** *** 79,83 **** self.failUnless(attr==win32file.GetFileAttributes(testName), "Expected GetFileAttributesEx to return the same attributes as GetFileAttributes") ! h = None # Close the file by removing the last reference to the handle! --- 78,82 ---- self.failUnless(attr==win32file.GetFileAttributes(testName), "Expected GetFileAttributesEx to return the same attributes as GetFileAttributes") ! h = None # Close the file by removing the last reference to the handle! |
From: Mark H. <mha...@us...> - 2009-01-08 02:56:30
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1486/com/win32com/src Modified Files: PyComHelpers.cpp oleargs.cpp Log Message: Rationalize pywin32 time api and use of it, including removal of support for MS_WINCE, on the road to optionally using timezone-aware datetime objects. Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PyComHelpers.cpp 19 Dec 2008 02:28:48 -0000 1.17 --- PyComHelpers.cpp 8 Jan 2009 02:56:17 -0000 1.18 *************** *** 330,342 **** if (!PyWinObject_AsULARGE_INTEGER(obSize, &pStat->cbSize)) return FALSE; ! if (!PyTime_Check(obmtime) || !PyTime_Check(obctime) || !PyTime_Check(obatime)) { PyErr_SetString(PyExc_TypeError, "The time entries in a STATSTG tuple must be PyTime objects"); return FALSE; } ! if (!((PyTime *)obmtime)->GetTime(&pStat->mtime)) return FALSE; ! if (!((PyTime *)obctime)->GetTime(&pStat->ctime)) return FALSE; ! if (!((PyTime *)obatime)->GetTime(&pStat->atime)) return FALSE; if (!PyWinObject_AsIID(obCLSID, &pStat->clsid)) --- 330,342 ---- if (!PyWinObject_AsULARGE_INTEGER(obSize, &pStat->cbSize)) return FALSE; ! if (!PyWinTime_Check(obmtime) || !PyWinTime_Check(obctime) || !PyWinTime_Check(obatime)) { PyErr_SetString(PyExc_TypeError, "The time entries in a STATSTG tuple must be PyTime objects"); return FALSE; } ! if (!PyWinObject_AsFILETIME(obmtime, &pStat->mtime)) return FALSE; ! if (!PyWinObject_AsFILETIME(obctime, &pStat->ctime)) return FALSE; ! if (!PyWinObject_AsFILETIME(obatime, &pStat->atime)) return FALSE; if (!PyWinObject_AsIID(obCLSID, &pStat->clsid)) Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** oleargs.cpp 13 Oct 2008 23:45:05 -0000 1.42 --- oleargs.cpp 8 Jan 2009 02:56:17 -0000 1.43 *************** *** 160,164 **** V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyTime_Check(obj) || PyObject_HasAttrString(obj, "timetuple")) { V_VT(var) = VT_DATE; --- 160,164 ---- V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyWinTime_Check(obj)) { V_VT(var) = VT_DATE; *************** *** 1302,1306 **** V_DATEREF(var) = &m_dateBuf; if (!VALID_BYREF_MISSING(obj)) { ! if ( !PyTime_Check(obj) ) BREAK_FALSE; if ( !PyWinObject_AsDATE(obj, V_DATEREF(var) ) ) BREAK_FALSE; } else --- 1302,1306 ---- V_DATEREF(var) = &m_dateBuf; if (!VALID_BYREF_MISSING(obj)) { ! if ( !PyWinTime_Check(obj) ) BREAK_FALSE; if ( !PyWinObject_AsDATE(obj, V_DATEREF(var) ) ) BREAK_FALSE; } else |
From: Mark H. <mha...@us...> - 2009-01-08 02:56:29
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1486/win32/test Modified Files: test_pywintypes.py test_win32file.py Log Message: Rationalize pywin32 time api and use of it, including removal of support for MS_WINCE, on the road to optionally using timezone-aware datetime objects. Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_win32file.py 7 Jan 2009 06:03:29 -0000 1.22 --- test_win32file.py 8 Jan 2009 02:56:18 -0000 1.23 *************** *** 6,14 **** import os import tempfile - import sets import threading import time import shutil import socket class TestSimpleOps(unittest.TestCase): --- 6,19 ---- import os import tempfile import threading import time import shutil import socket + import datetime + + try: + set + except NameError: + from sets import Set as set class TestSimpleOps(unittest.TestCase): *************** *** 117,120 **** --- 122,168 ---- os.unlink(filename) + def testFileTimes(self): + if issubclass(pywintypes.TimeType, datetime.datetime): + from win32timezone import GetLocalTimeZone + now = datetime.datetime.now(tz=GetLocalTimeZone()) + ok_delta = datetime.timedelta(seconds=1) + later = now + datetime.timedelta(seconds=120) + else: + tick = int(time.time()) + now = pywintypes.Time(tick) + ok_delta = 1 + later = pywintypes.Time(tick+120) + + filename = tempfile.mktemp("-testFileTimes") + # Windows docs the 'last time' isn't valid until the last write + # handle is closed - so create the file, then re-open it to check. + open(filename,"w").close() + f = win32file.CreateFile(filename, win32file.GENERIC_READ|win32file.GENERIC_WRITE, + 0, None, + win32con.OPEN_EXISTING, 0, None) + # *sob* - before we had tz aware datetime objects, we are faced + # with FILETIME objects being +GST out from now(). So just skip + # this... + if not issubclass(pywintypes.TimeType, datetime.datetime): + return + try: + ct, at, wt = win32file.GetFileTime(f) + self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) + self.failUnless( now <= ct <= now + ok_delta, (now, ct)) + self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) + self.failUnless( now <= wt <= now + ok_delta, (now, wt)) + + # Now set the times. + win32file.SetFileTime(f, later, later, later) + # Get them back. + ct, at, wt = win32file.GetFileTime(f) + self.failUnlessEqual(ct, later) + self.failUnlessEqual(at, later) + self.failUnlessEqual(wt, later) + + finally: + f.Close() + os.unlink(filename) + class TestOverlapped(unittest.TestCase): def testSimpleOverlapped(self): *************** *** 199,205 **** # reference counting should catch that error. overlapped = None ! self.failUnlessRaises(RuntimeError, ! win32file.GetQueuedCompletionStatus, port, -1) ! handle.Close() return --- 247,257 ---- # reference counting should catch that error. overlapped = None ! # even if we fail, be sure to close the handle; prevents hangs ! # on Vista 64... ! try: ! self.failUnlessRaises(RuntimeError, ! win32file.GetQueuedCompletionStatus, port, -1) ! finally: ! handle.Close() return *************** *** 232,236 **** t = threading.Thread(target=self._IOCPServerThread, args=(handle,port, test_overlapped_death)) - # hrmph - markh is seeing failures here on x64 - and a hang! t.setDaemon(True) # avoid hanging entire test suite on failure. t.start() --- 284,287 ---- *************** *** 321,327 **** dir = os.path.join(os.getcwd(), "*") files = win32file.FindFilesW(dir) ! set1 = sets.Set() set1.update(files) ! set2 = sets.Set() for file in win32file.FindFilesIterator(dir): set2.add(file) --- 372,378 ---- dir = os.path.join(os.getcwd(), "*") files = win32file.FindFilesW(dir) ! set1 = set() set1.update(files) ! set2 = set() for file in win32file.FindFilesIterator(dir): set2.add(file) Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_pywintypes.py 7 Jan 2009 06:03:29 -0000 1.5 --- test_pywintypes.py 8 Jan 2009 02:56:18 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- import time from pywin32_testutil import str2bytes, ob2memory + import datetime class TestCase(unittest.TestCase): *************** *** 9,14 **** pytime_current = pywintypes.Time(struct_current) # try and test all the standard parts of the format ! format_string = "%a %A %b %B %c %d %H %I %j %m %M %p %S %U %w %W %x %X %y %Y %Z" ! self.assertEquals(pytime_current.Format(format_string), time.strftime(format_string, struct_current)) def testPyTimePrint(self): --- 10,18 ---- 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) ! v2 = time.strftime(fmt, struct_current) ! self.assertEquals(v1, v2, "format %s failed - %r != %r" % (fmt, v1, v2)) def testPyTimePrint(self): *************** *** 17,26 **** # (as hopefully this wont be true forever). So either working, or # ValueError is OK. - t = pywintypes.Time(-2) try: t.Format() except ValueError: return def testPyTimeCompare(self): t1 = pywintypes.Time(100) --- 21,35 ---- # (as hopefully this wont be true forever). So either working, or # ValueError is OK. try: + t = pywintypes.Time(-2) t.Format() except ValueError: return + def testTimeInDict(self): + d = {} + d['t1'] = pywintypes.Time(1) + self.failUnlessEqual(d['t1'], pywintypes.Time(1)) + def testPyTimeCompare(self): t1 = pywintypes.Time(100) *************** *** 36,39 **** --- 45,68 ---- self.failUnless(t2 > t1 ) + def testTimeTuple(self): + now = datetime.datetime.now() # has usec... + # timetuple() lost usec - pt must be <=... + pt = pywintypes.Time(now.timetuple()) + # *sob* - only if we have a datetime object can we compare like this. + if isinstance(pt, datetime.datetime): + self.failUnless(pt <= now) + + def testTimeTuplems(self): + now = datetime.datetime.now() # has usec... + tt = now.timetuple() + (now.microsecond // 1000,) + pt = pywintypes.Time(tt) + # we can't compare if using the old type, as it loses all sub-second res. + if isinstance(pt, datetime.datetime): + self.failUnlessEqual(now, pt) + + def testPyTimeFromTime(self): + t1 = pywintypes.Time(time.time()) + self.failUnless(pywintypes.Time(t1) is t1) + def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" |
From: Mark H. <mha...@us...> - 2009-01-08 02:56:29
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1486/com/win32comext/adsi/src Modified Files: PyADSIUtil.cpp Log Message: Rationalize pywin32 time api and use of it, including removal of support for MS_WINCE, on the road to optionally using timezone-aware datetime objects. Index: PyADSIUtil.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/src/PyADSIUtil.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyADSIUtil.cpp 4 Aug 2006 08:33:44 -0000 1.6 --- PyADSIUtil.cpp 8 Jan 2009 02:56:17 -0000 1.7 *************** *** 212,216 **** else if (PyInt_Check(val)) dwType = ADSTYPE_INTEGER; ! else if (PyTime_Check(val)) dwType = ADSTYPE_UTC_TIME; else { --- 212,216 ---- else if (PyInt_Check(val)) dwType = ADSTYPE_INTEGER; ! else if (PyWinTime_Check(val)) dwType = ADSTYPE_UTC_TIME; else { |
From: Mark H. <mha...@us...> - 2009-01-08 02:56:24
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1486/win32/src Modified Files: PyTime.cpp PyWinTypes.h PyWinTypesmodule.cpp odbc.cpp win32evtlog.i Log Message: Rationalize pywin32 time api and use of it, including removal of support for MS_WINCE, on the road to optionally using timezone-aware datetime objects. Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** odbc.cpp 8 Dec 2008 13:16:37 -0000 1.29 --- odbc.cpp 8 Jan 2009 02:56:17 -0000 1.30 *************** *** 885,889 **** ZeroMemory(dt, len); // Accept either a PyTime or datetime object ! if (PyTime_Check(item)){ SYSTEMTIME st; if (!((PyTime *)item)->GetTime(&st)) --- 885,890 ---- ZeroMemory(dt, len); // Accept either a PyTime or datetime object ! #ifndef NO_PYWINTYPES_TIME ! if (PyWinTime_CHECK(item)){ SYSTEMTIME st; if (!((PyTime *)item)->GetTime(&st)) *************** *** 899,902 **** --- 900,904 ---- } else{ + #endif // NO_PYWINTYPES_TIME // Python 2.3 doesn't have C Api for datetime TmpPyObject timeseq = PyObject_CallMethod(item, "timetuple", NULL); *************** *** 929,934 **** // Convert to nanoseconds dt->fraction *= 1000; - } } if (unsuccessful(SQLBindParameter( --- 931,938 ---- // Convert to nanoseconds dt->fraction *= 1000; } + #ifndef NO_PYWINTYPES_TIME + } + #endif // NO_PYWINTYPES_TIME if (unsuccessful(SQLBindParameter( *************** *** 1162,1166 **** rv = ibindFloat(cur, iCol, item); } ! else if (PyTime_Check(item) || PyObject_HasAttrString(item, "timetuple")) { rv = ibindDate(cur, iCol, item); --- 1166,1170 ---- rv = ibindFloat(cur, iCol, item); } ! else if (PyWinTime_Check(item)) { rv = ibindDate(cur, iCol, item); Index: win32evtlog.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32evtlog.i,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32evtlog.i 11 Dec 2008 00:25:40 -0000 1.8 --- win32evtlog.i 8 Jan 2009 02:56:18 -0000 1.9 *************** *** 141,146 **** } ! TimeGenerated = PyWinTimeObject_FromLong(pEvt->TimeGenerated); ! TimeWritten = PyWinTimeObject_FromLong(pEvt->TimeWritten); if (pEvt->UserSidLength==0) { --- 141,146 ---- } ! TimeGenerated = PyWinTimeObject_Fromtime_t((time_t)pEvt->TimeGenerated); ! TimeWritten = PyWinTimeObject_Fromtime_t((time_t)pEvt->TimeWritten); if (pEvt->UserSidLength==0) { Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** PyWinTypesmodule.cpp 8 Dec 2008 13:16:37 -0000 1.47 --- PyWinTypesmodule.cpp 8 Jan 2009 02:56:17 -0000 1.48 *************** *** 23,26 **** --- 23,29 ---- extern PyObject *PyWinMethod_NewHKEY(PyObject *self, PyObject *args); + extern BOOL _PyWinDateTime_Init(); + extern BOOL _PyWinDateTime_PrepareModuleDict(PyObject *dict); + #ifdef MS_WINCE // Where is this supposed to come from on CE??? *************** *** 760,766 **** {"IID", PyWinMethod_NewIID, 1 }, // @pymeth IID|Makes an <o PyIID> object from a string. #endif ! #ifndef NO_PYWINTYPES_TIME ! {"Time", PyWinMethod_NewTime, 1 }, // @pymeth Time|Makes a <o PyTime> object from the argument. Argument can be an integer/float or a tuple (as returned by time module functions). ! #endif #ifndef MS_WINCE {"CreateGuid", PyWin_CreateGuid, 1 }, // @pymeth CreateGuid|Creates a new, unique GUIID. --- 763,767 ---- {"IID", PyWinMethod_NewIID, 1 }, // @pymeth IID|Makes an <o PyIID> object from a string. #endif ! {"Time", PyWinMethod_NewTime, 1 }, // @pymeth Time|Makes a <o PyTime> object from the argument. #ifndef MS_WINCE {"CreateGuid", PyWin_CreateGuid, 1 }, // @pymeth CreateGuid|Creates a new, unique GUIID. *************** *** 941,947 **** PYWIN_MODULE_INIT_RETURN_ERROR; ! #ifndef NO_PYWINTYPES_TIME ! ADD_TYPE(TimeType); ! #endif // NO_PYWINTYPES_TIME #ifndef NO_PYWINTYPES_IID ADD_TYPE(IIDType); --- 942,947 ---- PYWIN_MODULE_INIT_RETURN_ERROR; ! if (!_PyWinDateTime_PrepareModuleDict(dict)) ! PYWIN_MODULE_INIT_RETURN_ERROR; #ifndef NO_PYWINTYPES_IID ADD_TYPE(IIDType); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** PyWinTypes.h 3 Jan 2009 06:43:58 -0000 1.59 --- PyWinTypes.h 8 Jan 2009 02:56:17 -0000 1.60 *************** *** 470,473 **** --- 470,476 ---- ** TIME support */ + // 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); *************** *** 478,501 **** // LARGE_INTEGER prototype to avoid pulling in the windows security headers. PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t); PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate); PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate); ! #ifndef NO_PYWINTYPES_TIME ! extern PYWINTYPES_EXPORT PyTypeObject PyTimeType; // the Type for PyTime ! #define PyTime_Check(ob) ((ob)->ob_type == &PyTimeType) - PYWINTYPES_EXPORT PyObject *PyWinObject_FromDATE(DATE t); - PYWINTYPES_EXPORT PyObject *PyWinTimeObject_FromLong(long t); ! // A global function that can work as a module method for making a time object. ! PYWINTYPES_EXPORT PyObject *PyWinMethod_NewTime( PyObject *self, PyObject *args); ! #endif // NO_PYWINTYPES_TIME ! // Convert a time object to a time_t value. ! PYWINTYPES_EXPORT BOOL PyWinObject_Astime_t(PyObject *ob, time_t *t); // functions to return WIN32_FIND_DATA tuples, used in shell, win32api, and win32file --- 481,503 ---- // LARGE_INTEGER prototype to avoid pulling in the windows security headers. PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t); + PYWINTYPES_EXPORT PyObject *PyWinTimeObject_Fromtime_t(time_t t); + PYWINTYPES_EXPORT PyObject *PyWinObject_FromDATE(DATE t); PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate); PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate); ! // A global function that can work as a module method for making a time object. ! PYWINTYPES_EXPORT PyObject *PyWinMethod_NewTime( PyObject *self, PyObject *args); ! PYWINTYPES_EXPORT BOOL PyWinTime_Check(PyObject *ob); ! #ifndef NO_PYWINTYPES_TIME ! extern PYWINTYPES_EXPORT PyTypeObject PyTimeType; // the Type for PyTime ! #define PyWinTime_CHECK(ob) ((ob)->ob_type == &PyTimeType) ! #endif // NO_PYWINTYPES_TIME // functions to return WIN32_FIND_DATA tuples, used in shell, win32api, and win32file Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PyTime.cpp 11 Dec 2008 00:25:40 -0000 1.22 --- PyTime.cpp 8 Jan 2009 02:56:17 -0000 1.23 *************** *** 5,31 **** #include "PyWinTypes.h" #include "PyWinObjects.h" - #ifndef MS_WINCE #include "time.h" - #endif #include "tchar.h" - #ifndef NO_PYWINTYPES_TIME - - #ifdef MS_WINCE - #include <oleauto.h> // Time conversion functions on CE. - // The Python helpers. - BOOL PyCE_UnixTimeToFileTime(time_t t, LPFILETIME pft); - BOOL PyCE_UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst); - BOOL PyCE_FileTimeToUnixTime(FILETIME *pft, time_t *pt); - BOOL PyCE_SystemTimeToUnixTime(SYSTEMTIME *pst, time_t *pt); - void PyCE_TimeStructToSystemTime(struct tm *ptm, SYSTEMTIME *pst); - #endif - - #if _MSC_VER < 1100 - // MSVC < 5.0 headers dont have these - WINOLEAUTAPI_(INT) SystemTimeToVariantTime(LPSYSTEMTIME lpSystemTime, DOUBLE* pvtime); - WINOLEAUTAPI_(INT) VariantTimeToSystemTime(DOUBLE vtime, LPSYSTEMTIME lpSystemTime); - #endif - static WORD SequenceIndexAsWORD(PyObject *seq, int index) { --- 5,11 ---- *************** *** 36,41 **** --- 16,36 ---- } + BOOL PyWinTime_Check(PyObject *ob) + { + return 0 || + #ifndef NO_PYWINTYPES_TIME + PyWinTime_CHECK(ob) || + #endif + PyObject_HasAttrString(ob, "timetuple"); + } + PyObject *PyWin_NewTime(PyObject *timeOb) { + // If it already a datetime object, just return it as-is. + if (PyWinTime_CHECK(timeOb)) { + Py_INCREF(timeOb); + return timeOb; + } + PyObject *result = NULL; /***** Commented out temporarily *************** *** 129,135 **** return new PyTime(t); } ! PyObject *PyWinTimeObject_FromLong(long t) { ! return new PyTime((time_t)t); } --- 124,130 ---- return new PyTime(t); } ! PyObject *PyWinTimeObject_Fromtime_t(time_t t) { ! return new PyTime(t); } *************** *** 148,152 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 143,147 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 162,166 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 157,161 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 175,179 **** PyObject *newref = NULL; BOOL rc; ! if (!PyTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; --- 170,174 ---- PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_Check(ob)) { if (!(ob = PyWin_NewTime(ob))) return FALSE; *************** *** 323,331 **** // @xref <om pywintypes.Time> - #endif /* MS_WINCE */ struct PyMethodDef PyTime::methods[] = { - #ifndef MS_WINCE {"Format", PyTime::Format, 1}, // @pymeth Format|Formats the time value - #endif {NULL} }; --- 318,323 ---- *************** *** 424,441 **** ob_type = &PyTimeType; _Py_NewReference(this); - - #ifdef MS_WINCE - /* WinCE makes life harder than it should be! */ - FILETIME ftLocal, ftUTC; - PyCE_UnixTimeToFileTime( (time_t)t, &ftUTC); - FileTimeToLocalFileTime(&ftUTC, &ftLocal); - - time_t temp_t; - - PyCE_FileTimeToUnixTime(&ftLocal, &temp_t); - m_time = (double)temp_t; - - #else - /* "Normal" Win32 handling */ m_time = 0; struct tm *ptm = localtime(&t); --- 416,419 ---- *************** *** 454,458 **** (void)SystemTimeToVariantTime(&st, &m_time); } - #endif /* MS_WINCE */ } --- 432,435 ---- *************** *** 530,534 **** PyObject *PyTime::richcompare(PyObject *other, int op) { ! if (!PyTime_Check(other)){ PyErr_SetString(PyExc_TypeError, "PyTime cannot be compared to other types"); return NULL; --- 507,511 ---- PyObject *PyTime::richcompare(PyObject *other, int op) { ! if (!PyWinTime_Check(other)){ PyErr_SetString(PyExc_TypeError, "PyTime cannot be compared to other types"); return NULL; *************** *** 588,603 **** tm.tm_year = st.wYear - 1900; tm.tm_isdst = -1; /* have the library figure it out */ - - #ifdef MS_WINCE - /* Windows CE hacks! */ - FILETIME ft; - long t; - PyCE_TimeStructToSystemTime(&tm, &st); - SystemTimeToFileTime(&st, &ft); - PyCE_FileTimeToUnixTime(&ft, &t); - - return t; - #else - /* Normal win32 code */ long result = (long)mktime(&tm); if ( result == -1 ) --- 565,568 ---- *************** *** 607,611 **** } return result; - #endif } --- 572,575 ---- *************** *** 782,878 **** } ! #else // NO_PYWINTYPES_TIME ! // We dont have a decent time implementation, but ! // we need _some_ implementation of these functions! ! ! double PyCE_SystemTimeToCTime(SYSTEMTIME* pstTime) ! { ! SYSTEMTIME stBase; ! FILETIME ftTime; ! FILETIME ftBase; ! __int64 iTime; ! __int64 iBase; ! ! SystemTimeToFileTime(pstTime, &ftTime); ! ! stBase.wYear = 1970; ! stBase.wMonth = 1; ! stBase.wDayOfWeek = 1; ! stBase.wDay = 1; ! stBase.wHour = 0; ! stBase.wMinute = 0; ! stBase.wSecond = 0; ! stBase.wMilliseconds = 0; ! SystemTimeToFileTime(&stBase, &ftBase); ! ! iTime=ftTime.dwHighDateTime; ! iTime=iTime << 32; ! iTime |= ftTime.dwLowDateTime; ! ! iBase=ftBase.dwHighDateTime; ! iBase=iBase << 32; ! iBase |= ftBase.dwLowDateTime; ! ! return (double)((iTime - iBase) / 10000000L); ! } ! ! BOOL PyCE_UnixTimeToFileTime(time_t t, LPFILETIME pft) ! { ! // Note that LONGLONG is a 64-bit value ! LONGLONG ll; ! ll = ((__int64)t * 10000000) + 116444736000000000; ! // ll = Int32x32To64(t, 10000000) + 116444736000000000; ! pft->dwLowDateTime = (DWORD)ll; ! pft->dwHighDateTime = (DWORD)(ll >> 32); ! return TRUE; ! } ! ! // We expose some time functions, but just return ! // standard Python floats. We need a better solution! ! ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromSYSTEMTIME(const SYSTEMTIME &st) ! { ! return PyFloat_FromDouble(PyCE_SystemTimeToCTime((SYSTEMTIME *)&st)); ! } ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t) ! { ! SYSTEMTIME st; ! if (!FileTimeToSystemTime(&t, &st)) ! return PyInt_FromLong(-1); ! return PyFloat_FromDouble(PyCE_SystemTimeToCTime(&st)); ! } ! //PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) ! //{ ! //} ! PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *ft) ! { ! PyObject *intOb = PyNumber_Int(ob); ! if (intOb==NULL) return FALSE; ! time_t t = (time_t)PyInt_AsLong(intOb); ! BOOL rc = PyCE_UnixTimeToFileTime(t, ft); ! Py_DECREF(intOb); ! return rc; ! } ! PYWINTYPES_EXPORT BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *st) { - FILETIME ft; - if (!PyWinObject_AsFILETIME(ob, &ft)) - return FALSE; - if (!FileTimeToSystemTime(&ft, st)) { - PyErr_SetString(PyExc_TypeError, "The value is out of range for a SYSTEMTIME"); - return FALSE; - } return TRUE; } ! #endif // NO_PYWINTYPES_TIME ! ! PYWINTYPES_EXPORT BOOL PyWinObject_Astime_t(PyObject *ob, time_t *t) { ! // We need to get smarter about 64bit time_t values... ! *t = (time_t)PyInt_AsLong(ob); ! if (*t == -1 && PyErr_Occurred()) return FALSE; return TRUE; } --- 746,764 ---- } ! #endif // NO_PYWINTYPES_TIME ! // A couple of public functions used by the module init ! BOOL _PyWinDateTime_Init() { return TRUE; } ! BOOL _PyWinDateTime_PrepareModuleDict(PyObject *dict) { ! #ifndef NO_PYWINTYPES_TIME ! if (PyType_Ready(&PyTimeType)==-1 ! || PyDict_SetItemString(dict, "TimeType", (PyObject *)&PyTimeType) == -1) return FALSE; + #endif return TRUE; } |
From: Mark H. <mha...@us...> - 2009-01-08 02:56:23
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1486/com/win32com/src/extensions Modified Files: PyIStorage.cpp Log Message: Rationalize pywin32 time api and use of it, including removal of support for MS_WINCE, on the road to optionally using timezone-aware datetime objects. Index: PyIStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIStorage.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyIStorage.cpp 13 Nov 2008 04:04:51 -0000 1.5 --- PyIStorage.cpp 8 Jan 2009 02:56:17 -0000 1.6 *************** *** 406,431 **** FILETIME *pmtime=NULL, mtime; if (obpctime!=Py_None) { ! pctime = &ctime; ! if (!PyTime_Check(obpctime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpctime)->GetTime(pctime)) return NULL; } if (obpatime != Py_None) { ! patime = &atime; ! if (!PyTime_Check(obpatime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpatime)->GetTime(patime)) return NULL; } if (obpmtime != Py_None) { ! pmtime = &mtime; ! if (!PyTime_Check(obpmtime)) { ! PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object"); return NULL; ! } ! if (!((PyTime *)obpmtime)->GetTime(pmtime)) return NULL; } BSTR bstrName; --- 406,422 ---- FILETIME *pmtime=NULL, mtime; if (obpctime!=Py_None) { ! if (!PyWinObject_AsFILETIME(obpctime, &ctime)) return NULL; ! pctime = &ctime; } if (obpatime != Py_None) { ! if (!PyWinObject_AsFILETIME(obpatime, &atime)) return NULL; ! patime = &atime; } if (obpmtime != Py_None) { ! if (!PyWinObject_AsFILETIME(obpmtime, &mtime)) return NULL; ! pmtime = &mtime; } BSTR bstrName; |
From: Mark H. <mha...@us...> - 2009-01-08 02:46:18
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1131/win32/Lib Modified Files: win32timezone.py Log Message: fix error when there is no garbage to be removed Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32timezone.py 26 Nov 2008 08:39:33 -0000 1.12 --- win32timezone.py 8 Jan 2009 02:46:13 -0000 1.13 *************** *** 471,478 **** """It may be a bug in Vista, but in standard Windows Vista install (both 32-bit and 64-bit), it appears the TimeZoneKeyName returns a ! string with extraneous characters.""" # remove anything after and including the first null character. ! value, garbage = name.split('\x00',1) ! return value def GetTZCapabilities(): --- 471,482 ---- """It may be a bug in Vista, but in standard Windows Vista install (both 32-bit and 64-bit), it appears the TimeZoneKeyName returns a ! string with extraneous characters. ! >>> __TimeZoneKeyNameWorkaround("foo\\0xxx") ! 'foo' ! >>> __TimeZoneKeyNameWorkaround("foo") ! 'foo' ! """ # remove anything after and including the first null character. ! return name.split('\x00',1)[0] def GetTZCapabilities(): |
From: Mark H. <mha...@us...> - 2009-01-08 02:45:42
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1109/com/win32com/src Modified Files: PythonCOM.cpp Log Message: pythoncom.MakeTime and MakeIID are marked as deprecated and removed from autoduck Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** PythonCOM.cpp 19 Dec 2008 02:28:48 -0000 1.55 --- PythonCOM.cpp 8 Jan 2009 02:45:31 -0000 1.56 *************** *** 742,758 **** } - // @pymethod <o PyIID>|pythoncom|MakeIID|Creates a new IID object. static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! // @comm This is simply an alias for <om pywintypes.IID>. Please see that method ! // for details. return PyWinMethod_NewIID(self, args); } ! // @pymethod <o PyTime>|pythoncom|MakeTime|Creates a new time object. static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! // @comm This is simply an alias for <om pywintypes.Time>. Please see that method ! // for details. return PyWinMethod_NewTime(self, args); } --- 742,755 ---- } static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeIID is deprecated - please use pywintypes.IID() instead.", 1); return PyWinMethod_NewIID(self, args); } ! // no autoduct - this is deprecated. static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeTime is deprecated - please use pywintypes.Time() instead.", 1); return PyWinMethod_NewTime(self, args); } *************** *** 1898,1903 **** { "LoadRegTypeLib", pythoncom_loadregtypelib, 1 }, // @pymeth LoadRegTypeLib|Loads a registered type library by CLSID { "LoadTypeLib", pythoncom_loadtypelib, 1 }, // @pymeth LoadTypeLib|Loads a type library by name ! { "MakeIID", pythoncom_MakeIID, 1 }, // @pymeth MakeIID|Makes an IID object from a string. ! { "MakeTime", pythoncom_MakeTime, 1 }, // @pymeth MakeTime|Makes a time object from the argument. Argument can be an integer/float or a tuple (as returned by time module functions). { "MakePyFactory", pythoncom_MakePyFactory, 1 }, // @pymeth MakePyFactory|Creates a new <o PyIClassFactory> object wrapping a PythonCOM Class Factory object. #ifndef MS_WINCE --- 1895,1900 ---- { "LoadRegTypeLib", pythoncom_loadregtypelib, 1 }, // @pymeth LoadRegTypeLib|Loads a registered type library by CLSID { "LoadTypeLib", pythoncom_loadtypelib, 1 }, // @pymeth LoadTypeLib|Loads a type library by name ! { "MakeIID", pythoncom_MakeIID, 1 }, ! { "MakeTime", pythoncom_MakeTime, 1 }, { "MakePyFactory", pythoncom_MakePyFactory, 1 }, // @pymeth MakePyFactory|Creates a new <o PyIClassFactory> object wrapping a PythonCOM Class Factory object. #ifndef MS_WINCE |
From: Mark H. <mha...@us...> - 2009-01-08 02:14:21
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32229/Pythonwin Modified Files: Tag: py3k win32uimodule.cpp Log Message: always call OutputDebugStringA Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.39.2.12 retrieving revision 1.39.2.13 diff -C2 -d -r1.39.2.12 -r1.39.2.13 *** win32uimodule.cpp 7 Jan 2009 06:27:42 -0000 1.39.2.12 --- win32uimodule.cpp 8 Jan 2009 02:14:14 -0000 1.39.2.13 *************** *** 670,674 **** char *msg = GetPythonTraceback(type, value, traceback); if (msg) { ! OutputDebugString(msg); free(msg); } --- 670,674 ---- char *msg = GetPythonTraceback(type, value, traceback); if (msg) { ! OutputDebugStringA(msg); free(msg); } |
From: Mark H. <mha...@us...> - 2009-01-07 06:28:19
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7469/Pythonwin Modified Files: Tag: py3k win32win.cpp Log Message: 64bit handle fixes from py3k-integration branch Index: win32win.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v retrieving revision 1.21.2.4 retrieving revision 1.21.2.5 diff -C2 -d -r1.21.2.4 -r1.21.2.5 *** win32win.cpp 5 Jan 2009 12:51:26 -0000 1.21.2.4 --- win32win.cpp 7 Jan 2009 06:28:14 -0000 1.21.2.5 *************** *** 2711,2716 **** RETURN_ERR("BeginPaint failed"); PyObject *obDC = ui_assoc_object::make (ui_dc_object::type, pTemp)->GetGoodRet(); ! PyObject *obRet = Py_BuildValue("O(ii(iiii)iiN)", obDC, ! ps.hdc, ps.fErase, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, --- 2711,2716 ---- RETURN_ERR("BeginPaint failed"); PyObject *obDC = ui_assoc_object::make (ui_dc_object::type, pTemp)->GetGoodRet(); ! PyObject *obRet = Py_BuildValue("O(Ni(iiii)iiN)", obDC, ! PyWinLong_FromHANDLE(ps.hdc), ps.fErase, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, |