pywin32-checkins Mailing List for Python for Windows Extensions (Page 27)
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-13 22:57:19
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17485/Lib Modified Files: win32gui_struct.py Log Message: Make win32gui_struct py3k friendly by checking if win32gui itself is built with UNICODE defined and acting accordingly. Includes new tests and 64bit fixes. Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32gui_struct.py 4 May 2008 10:45:54 -0000 1.11 --- win32gui_struct.py 13 Jan 2009 22:57:11 -0000 1.12 *************** *** 35,38 **** --- 35,61 ---- import pywintypes + # Encode a string suitable for passing in a win32gui related structure + # If win32gui is built with UNICODE defined (ie, py3k), then functions + # like InsertMenuItem are actually calling InsertMenuItemW etc, so all + # strings will need to be unicode. + if win32gui.UNICODE: + def _make_text_buffer(text): + # XXX - at this stage win32gui.UNICODE is only True in py3k, + # and in py3k is makes sense to reject bytes. + if not isinstance(text, unicode): + raise TypeError('MENUITEMINFO text must be unicode') + data = (text+'\0').encode("unicode-internal") + return array.array("b", data) + + else: + def _make_text_buffer(text): + if isinstance(text, unicode): + text = text.encode("mbcs") + return array.array("b", text+'\0') + + # make an 'empty' buffer, ready for filling with cch characters. + def _make_empty_text_buffer(cch): + return _make_text_buffer("\0" * cch) + # Generic WM_NOTIFY unpacking def UnpackWMNOTIFY(lparam): *************** *** 48,52 **** # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '5i5PiP' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, --- 71,75 ---- # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! _menuiteminfo_fmt = '5i5PiP' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, *************** *** 89,96 **** if text is not None: fMask |= win32con.MIIM_STRING ! if isinstance(text, unicode): ! text = text.encode("mbcs") ! str_buf = array.array("c", text+'\0') ! cch = len(str_buf) # We are taking address of strbuf - it must not die until windows # has finished with our structure. --- 112,117 ---- if text is not None: fMask |= win32con.MIIM_STRING ! str_buf = _make_text_buffer(text) ! cch = len(text) # We are taking address of strbuf - it must not die until windows # has finished with our structure. *************** *** 103,108 **** # 'P' format does not accept PyHANDLE's ! item = struct.pack( ! menuitem_fmt, ! struct.calcsize(menuitem_fmt), # cbSize fMask, fType, --- 124,129 ---- # 'P' format does not accept PyHANDLE's ! item = struct.pack( ! _menuiteminfo_fmt, ! struct.calcsize(_menuiteminfo_fmt), # cbSize fMask, fType, *************** *** 119,123 **** # Now copy the string to a writable buffer, so that the result # could be passed to a 'Get' function ! return array.array("c", item), extras def UnpackMENUITEMINFO(s): --- 140,144 ---- # Now copy the string to a writable buffer, so that the result # could be passed to a 'Get' function ! return array.array("b", item), extras def UnpackMENUITEMINFO(s): *************** *** 133,137 **** lptext, cch, ! hbmpItem) = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None --- 154,158 ---- lptext, cch, ! hbmpItem) = struct.unpack(_menuiteminfo_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None *************** *** 150,153 **** --- 171,175 ---- def EmptyMENUITEMINFO(mask = None, text_buf_size=512): + # text_buf_size is number of *characters* - not necessarily no of bytes. extra = [] if mask is None: *************** *** 159,171 **** if mask & win32con.MIIM_STRING: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 buf = struct.pack( ! menuitem_fmt, ! struct.calcsize(menuitem_fmt), # cbSize mask, 0, #fType, --- 181,195 ---- if mask & win32con.MIIM_STRING: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 + # Now copy the string to a writable buffer, so that the result + # could be passed to a 'Get' function buf = struct.pack( ! _menuiteminfo_fmt, ! struct.calcsize(_menuiteminfo_fmt), # cbSize mask, 0, #fType, *************** *** 177,187 **** 0, #dwItemData, text_addr, ! text_len, 0, #hbmpItem ) ! return array.array("c", buf), extra # MENUINFO struct ! menuinfo_fmt = '7i' def PackMENUINFO(dwStyle = None, cyMax = None, --- 201,211 ---- 0, #dwItemData, text_addr, ! text_buf_size, 0, #hbmpItem ) ! return array.array("b", buf), extra # MENUINFO struct ! _menuinfo_fmt = 'iiiiPiP' def PackMENUINFO(dwStyle = None, cyMax = None, *************** *** 200,205 **** # Create the struct. item = struct.pack( ! menuinfo_fmt, ! struct.calcsize(menuinfo_fmt), # cbSize fMask, dwStyle, --- 224,229 ---- # Create the struct. item = struct.pack( ! _menuinfo_fmt, ! struct.calcsize(_menuinfo_fmt), # cbSize fMask, dwStyle, *************** *** 208,212 **** dwContextHelpID, dwMenuData) ! return array.array("c", item) def UnpackMENUINFO(s): --- 232,236 ---- dwContextHelpID, dwMenuData) ! return array.array("b", item) def UnpackMENUINFO(s): *************** *** 217,221 **** hbrBack, dwContextHelpID, ! dwMenuData) = struct.unpack(menuinfo_fmt, s) assert cb==len(s) if fMask & win32con.MIM_STYLE==0: dwStyle = None --- 241,245 ---- hbrBack, dwContextHelpID, ! dwMenuData) = struct.unpack(_menuinfo_fmt, s) assert cb==len(s) if fMask & win32con.MIM_STYLE==0: dwStyle = None *************** *** 233,238 **** buf = struct.pack( ! menuinfo_fmt, ! struct.calcsize(menuinfo_fmt), # cbSize mask, 0, #dwStyle --- 257,262 ---- buf = struct.pack( ! _menuinfo_fmt, ! struct.calcsize(_menuinfo_fmt), # cbSize mask, 0, #dwStyle *************** *** 242,246 **** 0, #dwMenuData, ) ! return array.array("c", buf) ########################################################################## --- 266,270 ---- 0, #dwMenuData, ) ! return array.array("b", buf) ########################################################################## *************** *** 288,296 **** text_addr = text_len = 0 else: ! if isinstance(text, unicode): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, --- 312,319 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) ! text_len = len(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, *************** *** 300,304 **** image, selimage, citems, param) ! return array.array("c", buf), extra # Make a new buffer suitable for querying hitem's attributes. --- 323,327 ---- image, selimage, citems, param) ! return array.array("b", buf), extra # Make a new buffer suitable for querying hitem's attributes. *************** *** 310,326 **** commctrl.TVIF_CHILDREN | commctrl.TVIF_PARAM if mask & commctrl.TVIF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, hitem, 0, 0, ! text_addr, text_len, # text 0, 0, 0, 0) ! return array.array("c", buf), extra def UnpackTVITEM(buffer): --- 333,349 ---- commctrl.TVIF_CHILDREN | commctrl.TVIF_PARAM if mask & commctrl.TVIF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, hitem, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0, 0) ! return array.array("b", buf), extra def UnpackTVITEM(buffer): *************** *** 389,397 **** else: mask |= commctrl.LVIF_TEXT ! if isinstance(text, unicode): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, --- 412,419 ---- else: mask |= commctrl.LVIF_TEXT ! text_buffer = _make_text_buffer(text) ! text_len = len(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, *************** *** 400,404 **** text_addr, text_len, # text image, param, indent) ! return array.array("c", buf), extra def UnpackLVITEM(buffer): --- 422,426 ---- text_addr, text_len, # text image, param, indent) ! return array.array("b", buf), extra def UnpackLVITEM(buffer): *************** *** 445,460 **** commctrl.LVIF_PARAM | commctrl.LVIF_STATE if mask & commctrl.LVIF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, item, subitem, 0, 0, ! text_addr, text_len, # text 0, 0, 0) ! return array.array("c", buf), extra --- 467,482 ---- commctrl.LVIF_PARAM | commctrl.LVIF_STATE if mask & commctrl.LVIF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, item, subitem, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0) ! return array.array("b", buf), extra *************** *** 472,480 **** text_addr = text_len = 0 else: ! if isinstance(text, unicode): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiii" buf = struct.pack(format, --- 494,501 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() ! text_len = len(text) format = "iiiiiiii" buf = struct.pack(format, *************** *** 482,486 **** text_addr, text_len, # text subItem, image, order) ! return array.array("c", buf), extra def UnpackLVCOLUMN(lparam): --- 503,507 ---- text_addr, text_len, # text subItem, image, order) ! return array.array("b", buf), extra def UnpackLVCOLUMN(lparam): *************** *** 509,523 **** commctrl.LVCF_SUBITEM | commctrl.LVCF_IMAGE | commctrl.LVCF_ORDER if mask & commctrl.LVCF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiii" buf = struct.pack(format, mask, 0, 0, ! text_addr, text_len, # text 0, 0, 0) ! return array.array("c", buf), extra # List view hit-test. --- 530,544 ---- commctrl.LVCF_SUBITEM | commctrl.LVCF_IMAGE | commctrl.LVCF_ORDER if mask & commctrl.LVCF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiii" buf = struct.pack(format, mask, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0) ! return array.array("b", buf), extra # List view hit-test. *************** *** 527,531 **** pt[0], pt[1], 0, 0, 0) ! return array.array("c", buf), None def UnpackLVHITTEST(buf): --- 548,552 ---- pt[0], pt[1], 0, 0, 0) ! return array.array("b", buf), None def UnpackLVHITTEST(buf): *************** *** 549,557 **** text_addr = text_len = 0 else: ! if isinstance(text, unicode): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiiii" --- 570,577 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() ! text_len = len(text) format = "iiiiiiiiiii" *************** *** 559,563 **** mask, cxy, text_addr, hbm, text_len, fmt, param, image, order, 0, 0) ! return array.array("c", buf), extra # Device notification stuff --- 579,583 ---- mask, cxy, text_addr, hbm, text_len, fmt, param, image, order, 0, 0) ! return array.array("b", buf), extra # Device notification stuff |
From: Mark H. <mha...@us...> - 2009-01-13 22:57:19
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17485/test Added Files: test_win32guistruct.py Log Message: Make win32gui_struct py3k friendly by checking if win32gui itself is built with UNICODE defined and acting accordingly. Includes new tests and 64bit fixes. --- NEW FILE: test_win32guistruct.py --- import unittest import win32gui import win32gui_struct import win32con class TestBase(unittest.TestCase): def assertDictEquals(self, d, **kw): checked = dict() for n, v in kw.iteritems(): self.failUnlessEqual(v, d[n], "'%s' doesn't match: %r != %r" % (n, v, d[n])) checked[n] = True checked_keys = checked.keys() passed_keys = kw.keys() checked_keys.sort() passed_keys.sort() self.failUnlessEqual(checked_keys, passed_keys) class TestMenuItemInfo(TestBase): def _testPackUnpack(self, text): vals = dict(fType=win32con.MFT_MENUBARBREAK, fState=win32con.MFS_CHECKED, wID=123, hSubMenu=1234, hbmpChecked=12345, hbmpUnchecked=123456, dwItemData=1234567, text=text, hbmpItem=321) mii, extras = win32gui_struct.PackMENUITEMINFO(**vals) fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ dwItemData, text, hbmpItem = win32gui_struct.UnpackMENUITEMINFO(mii) self.assertDictEquals(vals, fType=fType, fState=fState, wID=wID, hSubMenu=hSubMenu, hbmpChecked=hbmpChecked, hbmpUnchecked=hbmpUnchecked, dwItemData=dwItemData, text=text, hbmpItem=hbmpItem) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmptyMenuItemInfo(self): mii, extra = win32gui_struct.EmptyMENUITEMINFO() fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ dwItemData, text, hbmpItem = win32gui_struct.UnpackMENUITEMINFO(mii) self.failUnlessEqual(fType, 0) self.failUnlessEqual(fState, 0) self.failUnlessEqual(wID, 0) self.failUnlessEqual(hSubMenu, 0) self.failUnlessEqual(hbmpChecked, 0) self.failUnlessEqual(hbmpUnchecked, 0) self.failUnlessEqual(dwItemData, 0) self.failUnlessEqual(hbmpItem, 0) # it's not clear if UnpackMENUITEMINFO() should ignore cch, instead # assuming it is a buffer size rather than 'current length' - but it # never has (and this gives us every \0 in the string), and actually # helps us test the unicode/str semantics. self.failUnlessEqual(text, '\0' * len(text)) class TestMenuInfo(TestBase): def testPackUnpack(self): vals = dict(dwStyle=1, cyMax=2, hbrBack=3, dwContextHelpID=4, dwMenuData=5) mi = win32gui_struct.PackMENUINFO(**vals) dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData = \ win32gui_struct.UnpackMENUINFO(mi) self.assertDictEquals(vals, dwStyle=dwStyle, cyMax=cyMax, hbrBack=hbrBack, dwContextHelpID=dwContextHelpID, dwMenuData=dwMenuData) def testEmptyMenuItemInfo(self): mi = win32gui_struct.EmptyMENUINFO() dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData = \ win32gui_struct.UnpackMENUINFO(mi) self.failUnlessEqual(dwStyle, 0) self.failUnlessEqual(cyMax, 0) self.failUnlessEqual(hbrBack, 0) self.failUnlessEqual(dwContextHelpID, 0) self.failUnlessEqual(dwMenuData, 0) class TestTreeViewItem(TestBase): def _testPackUnpack(self, text): vals = dict(hitem=1, state=2, stateMask=3, text=text, image=4, selimage=5, citems=6, param=7) ti, extra = win32gui_struct.PackTVITEM(**vals) hitem, state, stateMask, text, image, selimage, citems, param = \ win32gui_struct.UnpackTVITEM(ti) self.assertDictEquals(vals, hitem=hitem, state=state, stateMask=stateMask, text=text, image=image, selimage=selimage, citems=citems, param=param) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyTVITEM(0) hitem, state, stateMask, text, image, selimage, citems, param = \ win32gui_struct.UnpackTVITEM(ti) self.failUnlessEqual(hitem, 0) self.failUnlessEqual(state, 0) self.failUnlessEqual(stateMask, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(image, 0) self.failUnlessEqual(selimage, 0) self.failUnlessEqual(citems, 0) self.failUnlessEqual(param, 0) class TestListViewItem(TestBase): def _testPackUnpack(self, text): vals = dict(item=None, subItem=None, state=1, stateMask=2, text=text, image=3, param=4, indent=5) ti, extra = win32gui_struct.PackLVITEM(**vals) item, subItem, state, stateMask, text, image, param, indent = \ win32gui_struct.UnpackLVITEM(ti) # patch expected values. vals['item'] = 0 vals['subItem'] = 0 self.assertDictEquals(vals, item=item, subItem=subItem, state=state, stateMask=stateMask, text=text, image=image, param=param, indent=indent) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyLVITEM(1, 2) item, subItem, state, stateMask, text, image, param, indent = \ win32gui_struct.UnpackLVITEM(ti) self.failUnlessEqual(item, 1) self.failUnlessEqual(subItem, 2) self.failUnlessEqual(state, 0) self.failUnlessEqual(stateMask, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(image, 0) self.failUnlessEqual(param, 0) self.failUnlessEqual(indent, 0) class TestLVColumn(TestBase): def _testPackUnpack(self, text): vals = dict(fmt=1, cx=2, text=text, subItem=3, image=4, order=5) ti, extra = win32gui_struct.PackLVCOLUMN(**vals) fmt, cx, text, subItem, image, order = \ win32gui_struct.UnpackLVCOLUMN(ti) self.assertDictEquals(vals, fmt=fmt, cx=cx, text=text, subItem=subItem, image=image, order=order) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyLVCOLUMN() fmt, cx, text, subItem, image, order = \ win32gui_struct.UnpackLVCOLUMN(ti) self.failUnlessEqual(fmt, 0) self.failUnlessEqual(cx, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(subItem, 0) self.failUnlessEqual(image, 0) self.failUnlessEqual(order, 0) if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2009-01-13 22:57:17
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17485/src Modified Files: win32gui.i Log Message: Make win32gui_struct py3k friendly by checking if win32gui itself is built with UNICODE defined and acting accordingly. Includes new tests and 64bit fixes. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** win32gui.i 11 Dec 2008 05:09:51 -0000 1.122 --- win32gui.i 13 Jan 2009 22:57:11 -0000 1.123 *************** *** 273,276 **** --- 273,284 ---- #endif + PyDict_SetItemString(d, "UNICODE", + #ifdef UNICODE + Py_True + #else + Py_False + #endif + ); + // hack borrowed from win32security since version of SWIG we use doesn't do keyword arguments #ifdef WINXPGUI *************** *** 1584,1591 **** %{ ! // @pyswig bytes|PyGetString|Returns bytes from an address. static PyObject *PyGetString(PyObject *self, PyObject *args) { ! char *addr = 0; size_t len = -1; #ifdef _WIN64 --- 1592,1600 ---- %{ ! // @pyswig string|PyGetString|Returns a string from an address. ! // @rdesc If win32gui.UNICODE is True, this will return a unicode object. static PyObject *PyGetString(PyObject *self, PyObject *args) { ! TCHAR *addr = 0; size_t len = -1; #ifdef _WIN64 *************** *** 1608,1619 **** return NULL; } ! return PyString_FromStringAndSize(addr, len); } // This should probably be in a __try just in case. ! if (IsBadStringPtrA(addr, (DWORD_PTR)-1)) { PyErr_SetString(PyExc_ValueError, "The value is not a valid null-terminated string"); return NULL; } ! return PyString_FromString(addr); } %} --- 1617,1628 ---- return NULL; } ! return PyWinObject_FromTCHAR(addr, len); } // This should probably be in a __try just in case. ! if (IsBadStringPtr(addr, (DWORD_PTR)-1)) { PyErr_SetString(PyExc_ValueError, "The value is not a valid null-terminated string"); return NULL; } ! return PyWinObject_FromTCHAR(addr); } %} |
From: Mark H. <mha...@us...> - 2009-01-13 22:54:15
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17207/src Modified Files: PyLARGE_INTEGER.cpp Log Message: Merge py3k LARGE_INTEGER fixes from py3k branch Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyLARGE_INTEGER.cpp 11 Dec 2008 00:46:31 -0000 1.14 --- PyLARGE_INTEGER.cpp 13 Jan 2009 22:54:09 -0000 1.15 *************** *** 48,51 **** --- 48,53 ---- BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { + #if (PY_VERSION_HEX < 0x03000000) + // py2k - ints and longs are different, and we assume 'int' is 32bits. if (PyInt_Check(ob)) { // 32 bit integer value. *************** *** 57,74 **** ULISet32(*pResult, x); return TRUE; ! } else if (PyLong_Check(ob)) { pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); - } else { - PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); - long hiVal, loVal; - if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { - PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); - return FALSE; - } - pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; - return TRUE; } ! assert(0); // not reached. } --- 59,76 ---- ULISet32(*pResult, x); return TRUE; ! } ! #endif // py2k ! if (PyLong_Check(ob)) { pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); } ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; } |
From: Mark H. <mha...@us...> - 2009-01-13 22:53:02
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17040 Modified Files: win32gui_dialog.py Log Message: make py3k-friendly, fix 64bit issue, and remove old workaround Index: win32gui_dialog.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_dialog.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32gui_dialog.py 27 Nov 2008 11:11:11 -0000 1.12 --- win32gui_dialog.py 13 Jan 2009 22:52:57 -0000 1.13 *************** *** 72,76 **** vals.append(0) else: ! str_buf = array.array("c", val+'\0') vals.append(str_buf.buffer_info()[0]) vals.append(len(val)) --- 72,83 ---- vals.append(0) else: ! # Note this demo still works with byte strings. An ! # alternate strategy would be to use unicode natively ! # and use the 'W' version of the messages - eg, ! # LVM_SETITEMW etc. ! val = val + "\0" ! if isinstance(val, unicode): ! val = val.encode("mbcs") ! str_buf = array.array("b", val) vals.append(str_buf.buffer_info()[0]) vals.append(len(val)) *************** *** 294,307 **** def OnNotify(self, hwnd, msg, wparam, lparam): ! format = "iiiiiiiiiii" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, idFrom, code, iItem, iSubItem, uNewState, uOldState, uChanged, actionx, actiony, lParam \ = struct.unpack(format, buf) - # *sigh* - work around a problem with old commctrl modules, which had a - # bad value for PY_OU, which therefore cause most "control notification" - # messages to be wrong. - # Code that needs to work with both pre and post pywin32-204 must do - # this too. - code += commctrl.PY_0U if code == commctrl.NM_DBLCLK: print "Double click on item", iItem+1 --- 301,308 ---- def OnNotify(self, hwnd, msg, wparam, lparam): ! format = "PPiiiiiiiiP" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, idFrom, code, iItem, iSubItem, uNewState, uOldState, uChanged, actionx, actiony, lParam \ = struct.unpack(format, buf) if code == commctrl.NM_DBLCLK: print "Double click on item", iItem+1 |
From: Jason R. C. <ja...@us...> - 2009-01-13 04:02:41
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25895 Modified Files: win32timezone.py Log Message: Added a class and function to facilitate creating UTC zones. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32timezone.py 13 Jan 2009 03:43:24 -0000 1.15 --- win32timezone.py 13 Jan 2009 04:02:31 -0000 1.16 *************** *** 443,446 **** --- 443,510 ---- # 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): + # no need to make more than one of these + try: + 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.standardBiasOffset==self.ZERO + no_dst = other.fixedStandardTime == True + same_daylight_bias = no_dst or si.daylightBiasOffset==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): + 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 |
From: Jason R. C. <ja...@us...> - 2009-01-13 03:43:31
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23833 Modified Files: win32timezone.py Log Message: Rewrote GetLocalTimeZone to use the win32api to avoid brittle registry work. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32timezone.py 13 Jan 2009 03:30:44 -0000 1.14 --- win32timezone.py 13 Jan 2009 03:43:24 -0000 1.15 *************** *** 462,490 **** True """ ! tzRegKey = r'SYSTEM\CurrentControlSet\Control\TimeZoneInformation' ! local = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, tzRegKey) ! # if the user has not checked "Automatically adjust clock for daylight ! # saving changes" in the Date and Time Properties control, the standard ! # and daylight values will be the same. If this is the case, create a ! # timezone object fixed to standard time. ! fixStandardTime = local['StandardName'] == local['DaylightName'] and \ ! local['StandardBias'] == local['DaylightBias'] ! keyName = ['StandardName', 'TimeZoneKeyName'][sys.getwindowsversion() >= (6,)] ! standardName = local[keyName] ! standardName = __TimeZoneKeyNameWorkaround(standardName) return TimeZoneInfo(standardName, fixStandardTime) - def __TimeZoneKeyNameWorkaround(name): - """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(): """Run a few known tests to determine the capabilities of the time zone database --- 462,475 ---- True """ ! code, result = win32api.GetTimeZoneInformation() ! bias, standardName, standardTimeBegin, standardBias, daylightName, daylightBegin, daylightBias = 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 ! fixStandardTime = 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(standardName, fixStandardTime) def GetTZCapabilities(): """Run a few known tests to determine the capabilities of the time zone database |
From: Jason R. C. <ja...@us...> - 2009-01-13 03:30:50
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22184 Modified Files: win32timezone.py Log Message: Refactored win32timezone to encapsulate registry operations. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** win32timezone.py 8 Jan 2009 02:46:13 -0000 1.13 --- win32timezone.py 13 Jan 2009 03:30:44 -0000 1.14 *************** *** 137,140 **** --- 137,141 ---- import operator import warnings + from itertools import count import logging *************** *** 144,158 **** format = '3l8h8h' ! def __init__(self, key, name = None): ! if(not name and len(key) == struct.calcsize(self.format)): ! self.__init_from_bytes__(key) ! else: ! self.__init_from_reg_key__(key, name) ! ! def __init_from_reg_key__(self, key, name = None): ! if not name: ! key, name = os.path.split(key) ! value, type = _winreg.QueryValueEx(key, name) ! self.__init_from_bytes__(value) def __init_from_bytes__(self, bytes): --- 145,150 ---- format = '3l8h8h' ! def __init__(self, bytes): ! self.__init_from_bytes__(bytes) def __init_from_bytes__(self, bytes): *************** *** 218,223 **** def __init__(self, timeZoneName, fixedStandardTime=False): self.timeZoneName = timeZoneName ! key = self._FindTimeZoneKey() ! self._LoadInfoFromKey(key) self.fixedStandardTime = fixedStandardTime --- 210,214 ---- def __init__(self, timeZoneName, fixedStandardTime=False): self.timeZoneName = timeZoneName ! self._LoadInfoFromKey() self.fixedStandardTime = fixedStandardTime *************** *** 230,258 **** # English-based hard-coded time zones. timeZoneName = zoneNames.get(self.timeZoneName, self.timeZoneName) ! tzRegKeyPath = os.path.join(self.tzRegKey, timeZoneName) try: ! key = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, tzRegKeyPath) except: raise ValueError('Timezone Name %s not found.' % timeZoneName) ! return key def __getinitargs__(self): return (self.timeZoneName,) ! def _LoadInfoFromKey(self, key): """Loads the information from an opened time zone registry key into relevant fields of this TZI object""" ! self.displayName = _winreg.QueryValueEx(key, "Display")[0] ! self.standardName = _winreg.QueryValueEx(key, "Std")[0] ! self.daylightName = _winreg.QueryValueEx(key, "Dlt")[0] ! self.staticInfo = WinTZI(key, "TZI") self._LoadDynamicInfoFromKey(key) def _LoadDynamicInfoFromKey(self, key): try: ! dkey = _winreg.OpenKeyEx(key, 'Dynamic DST') except WindowsError: return - info = _RegKeyDict(dkey) del info['FirstEntry'] del info['LastEntry'] --- 221,249 ---- # English-based hard-coded time zones. timeZoneName = zoneNames.get(self.timeZoneName, self.timeZoneName) ! key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, self.tzRegKey) try: ! result = key.subkey(timeZoneName) except: raise ValueError('Timezone Name %s not found.' % timeZoneName) ! return result def __getinitargs__(self): return (self.timeZoneName,) ! def _LoadInfoFromKey(self): """Loads the information from an opened time zone registry key into relevant fields of this TZI object""" ! key = self._FindTimeZoneKey() ! self.displayName = key['Display'] ! self.standardName = key['Std'] ! self.daylightName = key['Dlt'] ! self.staticInfo = WinTZI(key['TZI']) self._LoadDynamicInfoFromKey(key) def _LoadDynamicInfoFromKey(self, key): try: ! info = key.subkey('Dynamic DST') except WindowsError: return del info['FirstEntry'] del info['LastEntry'] *************** *** 345,374 **** # helper methods for accessing the timezone info from the registry def _get_time_zone_key(subkey=None): "Return the registry key that stores time zone details" ! key = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, TimeZoneInfo.tzRegKey) if subkey: ! key = _winreg.OpenKeyEx(key, subkey) return key - _get_time_zone_key = staticmethod(_get_time_zone_key) def _get_time_zone_key_names(): "Returns the names of the (registry keys of the) time zones" ! return _RegKeyEnumerator(TimeZoneInfo._get_time_zone_key()) ! _get_time_zone_key_names = staticmethod(_get_time_zone_key_names) ! def _get_indexed_time_zone_keys(index_key='Index'): """ Get the names of the registry keys indexed by a value in that key. """ ! key_names = tuple(TimeZoneInfo._get_time_zone_key_names()) def get_index_value(key_name): key = TimeZoneInfo._get_time_zone_key(key_name) ! value, type = _winreg.QueryValueEx(key, index_key) ! return value values = map(get_index_value, key_names) return zip(values, key_names) - _get_indexed_time_zone_keys = staticmethod(_get_indexed_time_zone_keys) def get_sorted_time_zone_names(): "Return a list of time zone names that can be used to initialize TimeZoneInfo instances" --- 336,365 ---- # helper methods for accessing the timezone info from the registry + @staticmethod def _get_time_zone_key(subkey=None): "Return the registry key that stores time zone details" ! key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, TimeZoneInfo.tzRegKey) if subkey: ! key = key.subkey(subkey) return key + @staticmethod def _get_time_zone_key_names(): "Returns the names of the (registry keys of the) time zones" ! return TimeZoneInfo._get_time_zone_key().subkeys() ! ! @staticmethod def _get_indexed_time_zone_keys(index_key='Index'): """ Get the names of the registry keys indexed by a value in that key. """ ! key_names = TimeZoneInfo._get_time_zone_key_names() def get_index_value(key_name): key = TimeZoneInfo._get_time_zone_key(key_name) ! return key[index_key] values = map(get_index_value, key_names) return zip(values, key_names) + @staticmethod def get_sorted_time_zone_names(): "Return a list of time zone names that can be used to initialize TimeZoneInfo instances" *************** *** 376,385 **** get_standard_name = lambda tzi: tzi.standardName return map(get_standard_name, tzs) - get_sorted_time_zone_names = staticmethod(get_sorted_time_zone_names) def get_all_time_zones(): return map(TimeZoneInfo, TimeZoneInfo._get_time_zone_key_names()) - get_all_time_zones = staticmethod(get_all_time_zones) def get_sorted_time_zones(key=None): """ --- 367,376 ---- get_standard_name = lambda tzi: tzi.standardName return map(get_standard_name, tzs) + @staticmethod def get_all_time_zones(): return map(TimeZoneInfo, TimeZoneInfo._get_time_zone_key_names()) + @staticmethod def get_sorted_time_zones(key=None): """ *************** *** 394,419 **** zones.sort(key=key) return zones - get_sorted_time_zones = staticmethod(get_sorted_time_zones) - - def _RegKeyEnumerator(key): - return _RegEnumerator(key, _winreg.EnumKey) - - def _RegValueEnumerator(key): - return _RegEnumerator(key, _winreg.EnumValue) ! def _RegEnumerator(key, func): ! "Enumerates an open registry key as an iterable generator" ! index = 0 ! try: ! while 1: ! yield func(key, index) ! index += 1 ! except WindowsError: pass ! def _RegKeyDict(key): ! values = _RegValueEnumerator(key) ! values = tuple(values) ! return dict(map(lambda (name,value,type): (name,value), values)) # for backward compatibility def deprecated(func, name='Unknown'): --- 385,427 ---- zones.sort(key=key) return zones ! class _RegKeyDict(dict): ! def __init__(self, key): ! dict.__init__(self) ! self.key = key ! self.__load_values() ! @classmethod ! def open(cls, *args, **kargs): ! return _RegKeyDict(_winreg.OpenKeyEx(*args, **kargs)) ! ! def subkey(self, name): ! return _RegKeyDict(_winreg.OpenKeyEx(self.key, name)) ! ! def __load_values(self): ! get_name_value = lambda (name, value, type): (name, value) ! pairs = map(get_name_value, self._enumerate_reg_values(self.key)) ! self.update(pairs) ! ! def subkeys(self): ! return self._enumerate_reg_keys(self.key) + @staticmethod + def _enumerate_reg_values(key): + return _RegKeyDict._enumerate_reg(key, _winreg.EnumValue) + + @staticmethod + def _enumerate_reg_keys(key): + return _RegKeyDict._enumerate_reg(key, _winreg.EnumKey) + + @staticmethod + def _enumerate_reg(key, func): + "Enumerates an open registry key as an iterable generator" + try: + for index in count(): + yield func(key, index) + except WindowsError: pass + + # for backward compatibility def deprecated(func, name='Unknown'): *************** *** 455,460 **** """ tzRegKey = r'SYSTEM\CurrentControlSet\Control\TimeZoneInformation' ! key = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, tzRegKey) ! local = _RegKeyDict(key) # if the user has not checked "Automatically adjust clock for daylight # saving changes" in the Date and Time Properties control, the standard --- 463,467 ---- """ tzRegKey = r'SYSTEM\CurrentControlSet\Control\TimeZoneInformation' ! local = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, tzRegKey) # if the user has not checked "Automatically adjust clock for daylight # saving changes" in the Date and Time Properties control, the standard |
From: Mark H. <mha...@us...> - 2009-01-12 08:51:15
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11049 Modified Files: setup.py Log Message: Get axdebug building again... Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** setup.py 8 Jan 2009 04:22:04 -0000 1.90 --- setup.py 12 Jan 2009 08:51:03 -0000 1.91 *************** *** 29,35 **** The 'exchange' extensions require headers that are no longer in any current SDKs, so these fail to build, but the 'mapi' extension should still build. ! Also, 'axdebug' once worked with recent Platform SDKs, with no ! additional software was needed - but currently this extension is known to not ! build. Building: --- 29,45 ---- The 'exchange' extensions require headers that are no longer in any current SDKs, so these fail to build, but the 'mapi' extension should still build. ! ! To build the axdebug extension for 32bit Python, follow these instructions: ! ! * Download the "Internet Explorer 4.01 Refresh of the Internet Client SDK" ! from http://support.microsoft.com/kb/q177877/. ! * The download is a self-extracting archive - execute it and unzip the ! contents to a 'temp' directory. ! * From that directory, copy 'include/axdebug.h' and 'lib/msdbg.lib' to ! somewhere the build process will find them - the 'include' and 'lib' ! directories of your SDK installation works. ! ! Note that no equivalent SDK for 64bit operating systems appears available, ! so this extension does not build on 64bit versions. Building: *************** *** 801,805 **** # Copy cpp lib files needed to create Python COM extensions clib_files = (['win32', 'pywintypes%s.lib'], ! ['win32com', 'pythoncom%s.lib']) for clib_file in clib_files: target_dir = os.path.join(self.build_lib, clib_file[0], "libs") --- 811,816 ---- # Copy cpp lib files needed to create Python COM extensions clib_files = (['win32', 'pywintypes%s.lib'], ! ['win32com', 'pythoncom%s.lib'], ! ['axscript', 'axscript%s.lib']) for clib_file in clib_files: target_dir = os.path.join(self.build_lib, clib_file[0], "libs") *************** *** 1459,1462 **** --- 1470,1474 ---- 'shell' : 'com/win32comext/shell/src', 'axcontrol' : 'com/win32comext/axcontrol/src', + 'axdebug' : 'com/win32comext/axdebug/src', 'mapi' : 'com/win32comext/mapi/src', 'authorization' : 'com/win32comext/authorization/src', *************** *** 1508,1511 **** --- 1520,1524 ---- dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], + implib_name="axscript.lib", pch_header = "stdafx.h" ), *************** *** 1513,1520 **** # module for details on getting it built. WinExt_win32com('axdebug', ! dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript", ! pch_header = "stdafx.h", ! optional_headers = ["activdbg.h"], ), WinExt_win32com('internet'), --- 1526,1578 ---- # module for details on getting it built. WinExt_win32com('axdebug', ! libraries="axscript msdbg", ! pch_header="stdafx.h", ! optional_headers=["activdbg.h"], ! sources=(""" ! %(axdebug)s/AXDebug.cpp ! %(axdebug)s/PyIActiveScriptDebug.cpp ! %(axdebug)s/PyIActiveScriptErrorDebug.cpp ! %(axdebug)s/PyIActiveScriptSiteDebug.cpp ! %(axdebug)s/PyIApplicationDebugger.cpp ! %(axdebug)s/PyIDebugApplication.cpp ! %(axdebug)s/PyIDebugApplicationNode.cpp ! %(axdebug)s/PyIDebugApplicationNodeEvents.cpp ! %(axdebug)s/PyIDebugApplicationThread.cpp ! %(axdebug)s/PyIDebugCodeContext.cpp ! %(axdebug)s/PyIDebugDocument.cpp ! %(axdebug)s/PyIDebugDocumentContext.cpp ! %(axdebug)s/PyIDebugDocumentHelper.cpp ! %(axdebug)s/PyIDebugDocumentHost.cpp ! %(axdebug)s/PyIDebugDocumentInfo.cpp ! %(axdebug)s/PyIDebugDocumentProvider.cpp ! %(axdebug)s/PyIDebugDocumentText.cpp ! %(axdebug)s/PyIDebugDocumentTextAuthor.cpp ! %(axdebug)s/PyIDebugDocumentTextEvents.cpp ! %(axdebug)s/PyIDebugDocumentTextExternalAuthor.cpp ! %(axdebug)s/PyIDebugExpression.cpp ! %(axdebug)s/PyIDebugExpressionCallBack.cpp ! %(axdebug)s/PyIDebugExpressionContext.cpp ! %(axdebug)s/PyIDebugProperties.cpp ! %(axdebug)s/PyIDebugSessionProvider.cpp ! %(axdebug)s/PyIDebugStackFrame.cpp ! %(axdebug)s/PyIDebugStackFrameSniffer.cpp ! %(axdebug)s/PyIDebugStackFrameSnifferEx.cpp ! %(axdebug)s/PyIDebugSyncOperation.cpp ! %(axdebug)s/PyIEnumDebugApplicationNodes.cpp ! %(axdebug)s/PyIEnumDebugCodeContexts.cpp ! %(axdebug)s/PyIEnumDebugExpressionContexts.cpp ! %(axdebug)s/PyIEnumDebugPropertyInfo.cpp ! %(axdebug)s/PyIEnumDebugStackFrames.cpp ! %(axdebug)s/PyIEnumRemoteDebugApplications.cpp ! %(axdebug)s/PyIEnumRemoteDebugApplicationThreads.cpp ! %(axdebug)s/PyIMachineDebugManager.cpp ! %(axdebug)s/PyIMachineDebugManagerEvents.cpp ! %(axdebug)s/PyIProcessDebugManager.cpp ! %(axdebug)s/PyIProvideExpressionContexts.cpp ! %(axdebug)s/PyIRemoteDebugApplication.cpp ! %(axdebug)s/PyIRemoteDebugApplicationEvents.cpp ! %(axdebug)s/PyIRemoteDebugApplicationThread.cpp ! %(axdebug)s/stdafx.cpp ! """ % dirs).split(), ), WinExt_win32com('internet'), |
From: Mark H. <mha...@us...> - 2009-01-12 08:51:13
|
Update of /cvsroot/pywin32/pywin32/com In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11049/com Removed Files: Active Debugging.dsp Log Message: Get axdebug building again... --- Active Debugging.dsp DELETED --- |
From: Mark H. <mha...@us...> - 2009-01-12 05:41:46
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv793 Modified Files: oleargs.cpp Log Message: merge py3k support from Roger's py3k branch Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** oleargs.cpp 8 Jan 2009 02:56:17 -0000 1.43 --- oleargs.cpp 12 Jan 2009 05:41:40 -0000 1.44 *************** *** 6,11 **** #include "PythonCOM.h" - extern void PyCom_LogF(const TCHAR *fmt, ...); - extern PyObject *PyObject_FromRecordInfo(IRecordInfo *, void *, ULONG); extern PyObject *PyObject_FromSAFEARRAYRecordInfo(SAFEARRAY *psa); --- 6,9 ---- *************** *** 18,34 **** #define BYREF_ARRAY_USE_EXISTING_ARRAY ! // A little helper just for this file ! static PyObject* OleSetTypeError(char *msg) ! { ! PyErr_SetString(PyExc_TypeError, msg); ! return NULL; ! } ! #ifdef UNICODE ! // In a Unicode environment, we provide a helper that ! // converts the argument to a string before raising the error. ! static PyObject* OleSetTypeErrorW(TCHAR *msg) { ! PyObject *obMsg = PyString_FromUnicode(msg); if (obMsg) { PyErr_SetObject(PyExc_TypeError, obMsg); --- 16,30 ---- #define BYREF_ARRAY_USE_EXISTING_ARRAY ! // Need to put this in pywintypes.h with rest of compatibility macros ! #if (PY_VERSION_HEX < 0x03000000) ! #define PYWIN_BUFFER_CHECK PyBuffer_Check ! #else ! #define PYWIN_BUFFER_CHECK PyObject_CheckBuffer ! #endif ! // A little helper just for this file ! static PyObject* OleSetTypeError(TCHAR *msg) { ! PyObject *obMsg = PyWinObject_FromTCHAR(msg); if (obMsg) { PyErr_SetObject(PyExc_TypeError, obMsg); *************** *** 37,44 **** return NULL; } - #define OleSetTypeErrorT OleSetTypeErrorW - #else - #define OleSetTypeErrorT OleSetTypeError - #endif /////////////////////////////////////////////////////////// --- 33,36 ---- *************** *** 116,120 **** V_I4(var) = PyInt_AsLong(obj); } ! else if (PyInstance_Check(obj) && PyObject_HasAttrString(obj, "_oleobj_")) { if (PyCom_InterfaceFromPyInstanceOrObject(obj, IID_IDispatch, (void **)&V_DISPATCH(var), FALSE)) --- 108,112 ---- V_I4(var) = PyInt_AsLong(obj); } ! else if (PyObject_HasAttrString(obj, "_oleobj_")) { if (PyCom_InterfaceFromPyInstanceOrObject(obj, IID_IDispatch, (void **)&V_DISPATCH(var), FALSE)) *************** *** 166,170 **** return FALSE; } ! else if (PyBuffer_Check(obj)) { // We have a buffer object - convert to safe array of VT_UI1 if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_UI1)) --- 158,162 ---- return FALSE; } ! else if (PYWIN_BUFFER_CHECK(obj)) { // We have a buffer object - convert to safe array of VT_UI1 if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_UI1)) *************** *** 194,207 **** V_VT(var) = VT_CY; } ! /* ! else if (obj->ob_type == &AutomatedType) ! { ! } ! */ if (V_VT(var) == VT_EMPTY && !bGoodEmpty) { // Must ensure we have a Python error set if we fail! if (!PyErr_Occurred()) { char *extraMessage = ""; ! if (obj->ob_type->tp_as_buffer && obj->ob_type->tp_as_buffer->bf_getreadbuffer) extraMessage = " (but obtaining the buffer() of this object could)"; PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be converted to a COM VARIANT%s", obj->ob_type->tp_name, extraMessage); --- 186,195 ---- V_VT(var) = VT_CY; } ! if (V_VT(var) == VT_EMPTY && !bGoodEmpty) { // Must ensure we have a Python error set if we fail! if (!PyErr_Occurred()) { char *extraMessage = ""; ! if (obj->ob_type->tp_as_buffer) extraMessage = " (but obtaining the buffer() of this object could)"; PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be converted to a COM VARIANT%s", obj->ob_type->tp_name, extraMessage); *************** *** 232,236 **** /* ### note: we shouldn't see this, it is illegal in a VARIANT */ if (V_ISVECTOR(var)) { ! return OleSetTypeError("Cant convert vectors!"); } --- 220,224 ---- /* ### note: we shouldn't see this, it is illegal in a VARIANT */ if (V_ISVECTOR(var)) { ! return OleSetTypeError(_T("Cant convert vectors!")); } *************** *** 270,279 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= (unsigned)PyInt_GetMax()) result = PyInt_FromLong(V_UI4(&varValue)); else --- 258,267 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= INT_MAX) result = PyInt_FromLong(V_UI4(&varValue)); else *************** *** 290,294 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } --- 278,282 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } *************** *** 308,312 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting floating point variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } --- 296,300 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting floating point variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } *************** *** 371,375 **** TCHAR buf[200]; wsprintf(buf, _T("The Variant type (0x%x) is not supported, and it can not be converted to a string"), V_VT(var)); ! OleSetTypeErrorT(buf); break; } --- 359,363 ---- TCHAR buf[200]; wsprintf(buf, _T("The Variant type (0x%x) is not supported, and it can not be converted to a string"), V_VT(var)); ! OleSetTypeError(buf); break; } *************** *** 392,397 **** { LONG numElements = pBounds[dimNo-1].cElements; ! if ((LONG)PySequence_Length(obj)!=numElements) { ! OleSetTypeError("All dimensions must be a sequence of the same size"); return FALSE; } --- 380,385 ---- { LONG numElements = pBounds[dimNo-1].cElements; ! if ((LONG)PyObject_Length(obj)!=numElements) { ! OleSetTypeError(_T("All dimensions must be a sequence of the same size")); return FALSE; } *************** *** 400,427 **** // (only support single segment buffers for now) if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { ! PyBufferProcs *pb = obj->ob_type->tp_as_buffer; ! Py_ssize_t bufSize; ! if (pb->bf_getreadbuffer && ! pb->bf_getsegcount && ! (*pb->bf_getsegcount)(obj, &bufSize)==1) ! { ! if (PyWin_SAFE_DOWNCAST(bufSize, Py_ssize_t, LONG) != numElements) { ! OleSetTypeError("Internal error - the buffer length is not the sequence length!"); ! return FALSE; } ! void *ob_buf, *sa_buf; ! HRESULT hr = SafeArrayAccessData(pSA,&sa_buf); ! if (FAILED(hr)) { ! PyCom_BuildPyException(hr); ! return FALSE; } ! pb->bf_getreadbuffer(obj, 0, &ob_buf); ! memcpy(sa_buf, ob_buf, bufSize); ! SafeArrayUnaccessData(pSA); ! // All done without a single loop :-) ! return TRUE; } // Otherwise just fall through into the standard mechanisms ! } BOOL ok = TRUE; for (int index=0;index<(int)numElements && ok;index++) { --- 388,413 ---- // (only support single segment buffers for now) if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { ! DWORD bufSize; ! void *ob_buf, *sa_buf; ! if (!PyWinObject_AsReadBuffer(obj, &ob_buf, &bufSize)) ! return FALSE; ! ! if (bufSize != numElements) { ! OleSetTypeError(_T("Internal error - the buffer length is not the sequence length!")); ! return FALSE; } ! ! HRESULT hr = SafeArrayAccessData(pSA,&sa_buf); ! if (FAILED(hr)) { ! PyCom_BuildPyException(hr); ! return FALSE; } ! memcpy(sa_buf, ob_buf, bufSize); ! SafeArrayUnaccessData(pSA); ! // All done without a single loop :-) ! return TRUE; } // Otherwise just fall through into the standard mechanisms ! BOOL ok = TRUE; for (int index=0;index<(int)numElements && ok;index++) { *************** *** 439,443 **** // Complex conversion. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError("Internal error - unexpected argument - only simple VARIANTTYPE expected"); ok = FALSE; } else { --- 425,429 ---- // Complex conversion. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError(_T("Internal error - unexpected argument - only simple VARIANTTYPE expected")); ok = FALSE; } else { *************** *** 484,575 **** static long PyCom_CalculatePyObjectDimension(PyObject *obItemCheck, long lDimension, PyObject* ppyobDimensionDictionary) { ! long lReturnDimension = lDimension; // Allow arbitrary sequences, but not strings or Unicode objects. ! if(obItemCheck && ! PySequence_Check(obItemCheck) && ! !PyString_Check(obItemCheck) && ! !PyUnicode_Check(obItemCheck)) ! { ! PyObject* ppyobDimension; ! PyObject* ppyobSize; ! PyObject* ppyobDimensionSize; ! PyObject* ppyobItem; ! Py_ssize_t lIndex; ! long lMinimalDimension = -1; ! long lActualDimension = -1; ! Py_ssize_t lObjectSize; ! if (PyBuffer_Check(obItemCheck)) ! // buffers are a special case - they define 1 new dimension. ! return lReturnDimension+1; ! // Retrieve the size of the object ! lObjectSize = PySequence_Length(obItemCheck); ! if (lObjectSize == -1) { ! /* has a __len__, but it failed. Treat as not a sequence */ ! assert(PyErr_Occurred()); // can't *really* have -1 elems! */ PyErr_Clear(); } ! if (lObjectSize != -1) { // A real sequence of size zero should be OK though. ! ppyobSize = PyInt_FromSsize_t(lObjectSize); ! // Retrieve the stored size in this dimension ! ppyobDimension = PyInt_FromLong(lDimension); ! // Note: No ref added by PyDict_GetItem ! ppyobDimensionSize = PyDict_GetItem(ppyobDimensionDictionary, ppyobDimension); ! if (NULL == ppyobDimensionSize) { ! // Not found so first element defines the size in this dimension PyErr_Clear(); ! PyDict_SetItem(ppyobDimensionDictionary, ppyobDimension, ppyobSize); ! } else { ! // Check if stored size in this dimension equals the size of the element to check ! Py_ssize_t lStoredSize = PyInt_AsSsize_t(ppyobDimensionSize); ! if (lStoredSize != lObjectSize) ! { ! // if not the same size => no new dimension ! Py_XDECREF(ppyobSize); ! Py_XDECREF(ppyobDimension); ! return lReturnDimension; ! } } ! Py_XDECREF(ppyobSize); ! Py_XDECREF(ppyobDimension); ! ! // A special case for a zero-length sequence - we accept this as ! // a new dimension, but no children to check. ! // ie an empty list has 1 dimension. ! if (lObjectSize==0) ! return lReturnDimension+1; ! ! // Now check for all elements in this list for their dimensionality ! // Their size is compared to the size stored in the dimension dictionary ! for(lIndex = 0; lIndex < lObjectSize; lIndex++) { ! ppyobItem = PySequence_GetItem(obItemCheck, lIndex); ! if (ppyobItem == NULL) { ! // Says it is a sequence, but getting the item failed. ! // (eg, may be a COM instance that has __getitem__, but fails when attempting) ! // Ignore the error, and pretend it is not a sequence. ! PyErr_Clear(); ! break; ! } ! // Call method recursively ! lActualDimension = PyCom_CalculatePyObjectDimension(ppyobItem, lDimension + 1, ppyobDimensionDictionary); ! if (-1 == lMinimalDimension) { ! // First call so store it lMinimalDimension = lActualDimension; - lReturnDimension = lActualDimension; - } else { - // Get the smallest dimension - if (lActualDimension < lMinimalDimension) { - lMinimalDimension = lActualDimension; - } - // Check if all dimensions of the sublist are equal - if (lReturnDimension != lActualDimension) { - // if not set the minimal dimension - lReturnDimension = lMinimalDimension; - } } ! Py_XDECREF(ppyobItem); } } } --- 470,561 ---- static long PyCom_CalculatePyObjectDimension(PyObject *obItemCheck, long lDimension, PyObject* ppyobDimensionDictionary) { ! // Buffers are a special case - they define 1 new dimension. ! // Buffers supported sequence semantics in 2.x, but for some reason memoryview objects ! // in py3k do not, so check separately ! if (PYWIN_BUFFER_CHECK(obItemCheck)) ! return lDimension+1; ! // Allow arbitrary sequences, but not strings or Unicode objects. ! if (PyString_Check(obItemCheck) || PyUnicode_Check(obItemCheck) ! ||!PySequence_Check(obItemCheck)) ! return lDimension; ! long lReturnDimension = lDimension; ! PyObject* ppyobDimension; ! PyObject* ppyobSize; ! PyObject* ppyobDimensionSize; ! PyObject* ppyobItem; ! Py_ssize_t lIndex; ! long lMinimalDimension = -1; ! long lActualDimension = -1; ! Py_ssize_t lObjectSize; ! // Retrieve the size of the object ! lObjectSize = PySequence_Length(obItemCheck); ! if (lObjectSize == -1) { ! /* has a __len__, but it failed. Treat as not a sequence */ ! assert(PyErr_Occurred()); // can't *really* have -1 elems! */ ! PyErr_Clear(); ! } ! if (lObjectSize != -1) { // A real sequence of size zero should be OK though. ! ppyobSize = PyInt_FromSsize_t(lObjectSize); ! ! // Retrieve the stored size in this dimension ! ppyobDimension = PyInt_FromLong(lDimension); ! // Note: No ref added by PyDict_GetItem ! ppyobDimensionSize = PyDict_GetItem(ppyobDimensionDictionary, ppyobDimension); ! if (NULL == ppyobDimensionSize) { ! // Not found so first element defines the size in this dimension PyErr_Clear(); + PyDict_SetItem(ppyobDimensionDictionary, ppyobDimension, ppyobSize); + } else { + // Check if stored size in this dimension equals the size of the element to check + Py_ssize_t lStoredSize = PyInt_AsSsize_t(ppyobDimensionSize); + if (lStoredSize != lObjectSize) + { + // if not the same size => no new dimension + Py_XDECREF(ppyobSize); + Py_XDECREF(ppyobDimension); + return lReturnDimension; + } } ! Py_XDECREF(ppyobSize); ! Py_XDECREF(ppyobDimension); ! // A special case for a zero-length sequence - we accept this as ! // a new dimension, but no children to check. ! // ie an empty list has 1 dimension. ! if (lObjectSize==0) ! return lReturnDimension+1; ! ! // Now check for all elements in this list for their dimensionality ! // Their size is compared to the size stored in the dimension dictionary ! for(lIndex = 0; lIndex < lObjectSize; lIndex++) { ! ppyobItem = PySequence_GetItem(obItemCheck, lIndex); ! if (ppyobItem == NULL) { ! // Says it is a sequence, but getting the item failed. ! // (eg, may be a COM instance that has __getitem__, but fails when attempting) ! // Ignore the error, and pretend it is not a sequence. PyErr_Clear(); ! break; } ! // Call method recursively ! lActualDimension = PyCom_CalculatePyObjectDimension(ppyobItem, lDimension + 1, ppyobDimensionDictionary); ! if (-1 == lMinimalDimension) { ! // First call so store it ! lMinimalDimension = lActualDimension; ! lReturnDimension = lActualDimension; ! } else { ! // Get the smallest dimension ! if (lActualDimension < lMinimalDimension) { lMinimalDimension = lActualDimension; } ! // Check if all dimensions of the sublist are equal ! if (lReturnDimension != lActualDimension) { ! // if not set the minimal dimension ! lReturnDimension = lMinimalDimension; ! } } + Py_XDECREF(ppyobItem); } } *************** *** 600,604 **** if (cDims==0) { ! OleSetTypeError("Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object."); return FALSE; } --- 586,590 ---- if (cDims==0) { ! OleSetTypeError(_T("Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object.")); return FALSE; } *************** *** 617,621 **** for (LONG dimLook = 1;dimLook <= cDims;dimLook++) { pBounds[dimLook-1].lLbound = 0; // always! ! pBounds[dimLook-1].cElements = PySequence_Length(obItemCheck); if (!bAllocNewArray) { LONG exist_lbound, exist_ubound; --- 603,608 ---- for (LONG dimLook = 1;dimLook <= cDims;dimLook++) { pBounds[dimLook-1].lLbound = 0; // always! ! // Don't use PySequence_Length due to memoryview not supporting sequence protocol ! pBounds[dimLook-1].cElements = PyObject_Length(obItemCheck); if (!bAllocNewArray) { LONG exist_lbound, exist_ubound; *************** *** 629,640 **** } } ! PyObject *obSave = obItemCheck; ! if (pBounds[dimLook-1].cElements) { ! obItemCheck = PySequence_GetItem(obItemCheck,0); ! Py_DECREF(obSave); ! if (obItemCheck==NULL) { ! Py_XDECREF(obItemCheck); ! delete [] pBounds; ! return FALSE; } } --- 616,629 ---- } } ! // Don't need to do this check if buffer is last dim ! if (!PYWIN_BUFFER_CHECK(obItemCheck)){ ! PyObject *obSave = obItemCheck; ! if (pBounds[dimLook-1].cElements) { ! obItemCheck = PySequence_GetItem(obItemCheck,0); ! Py_DECREF(obSave); ! if (obItemCheck==NULL) { ! delete [] pBounds; ! return FALSE; ! } } } *************** *** 807,811 **** TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type 0x%x is not supported for SAFEARRAYS"), vt); ! OleSetTypeErrorT(buf); } } --- 796,800 ---- TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type 0x%x is not supported for SAFEARRAYS"), vt); ! OleSetTypeError(buf); } } *************** *** 842,855 **** if (ret!=NULL) { // Access the buffer object using the buffer interfaces. ! PyBufferProcs *pb = ret->ob_type->tp_as_buffer; ! if (!pb->bf_getwritebuffer || ! !pb->bf_getsegcount || ! (*pb->bf_getsegcount)(ret, NULL)!=1) { ! PyErr_SetString(PyExc_RuntimeError, "New buffer has no buffer interfaces!!"); SafeArrayUnaccessData(psa); Py_DECREF(ret); return NULL; } - long count = pb->bf_getwritebuffer(ret, 0, &ob_buf); if (count != cElems) { PyErr_SetString(PyExc_RuntimeError, "buffer size is not what we created!"); --- 831,840 ---- if (ret!=NULL) { // Access the buffer object using the buffer interfaces. ! DWORD count; ! if (!PyWinObject_AsWriteBuffer(ret, &ob_buf, &count)){ SafeArrayUnaccessData(psa); Py_DECREF(ret); return NULL; } if (count != cElems) { PyErr_SetString(PyExc_RuntimeError, "buffer size is not what we created!"); *************** *** 900,904 **** // Our caller must has resolved all byref and array references. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError("Internal error - unexpected argument - only simple VARIANTTYPE expected"); return FALSE; } --- 885,889 ---- // Our caller must has resolved all byref and array references. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError(_T("Internal error - unexpected argument - only simple VARIANTTYPE expected")); return FALSE; } *************** *** 1060,1064 **** } if (m_reqdType & VT_VECTOR) { // we have been asked for an array. ! OleSetTypeError("Sorry - cant support VT_VECTOR arguments"); return FALSE; } --- 1045,1049 ---- } if (m_reqdType & VT_VECTOR) { // we have been asked for an array. ! OleSetTypeError(_T("Sorry - cant support VT_VECTOR arguments")); return FALSE; } *************** *** 1347,1351 **** TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type is unknown (0x%08lx)"), m_reqdType); ! OleSetTypeErrorT(buf); rc = FALSE; break; --- 1332,1336 ---- TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type is unknown (0x%08lx)"), m_reqdType); ! OleSetTypeError(buf); rc = FALSE; break; |
From: Mark H. <mha...@us...> - 2009-01-09 01:29:39
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16237 Modified Files: build.py genpy.py Log Message: avoid deprecated pythoncom.MakeTime Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** genpy.py 4 Dec 2008 07:03:39 -0000 1.63 --- genpy.py 9 Jan 2009 01:29:29 -0000 1.64 *************** *** 827,831 **** print >> self.file, 'python_version = 0x%x' % (sys.hexversion,) print >> self.file ! print >> self.file, 'import win32com.client.CLSIDToClass, pythoncom' print >> self.file, 'import win32com.client.util' print >> self.file, 'from pywintypes import IID' --- 827,831 ---- print >> self.file, 'python_version = 0x%x' % (sys.hexversion,) print >> self.file ! print >> self.file, 'import win32com.client.CLSIDToClass, pythoncom, pywintypes' print >> self.file, 'import win32com.client.util' print >> self.file, 'from pywintypes import IID' Index: build.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** build.py 7 Jan 2009 04:10:24 -0000 1.37 --- build.py 9 Jan 2009 01:29:29 -0000 1.38 *************** *** 559,563 **** if type(val) is TimeType: year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec ! return "pythoncom.MakeTime((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals() else: return repr(val) --- 559,563 ---- if type(val) is TimeType: year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec ! return "pywintypes.Time((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals() else: return repr(val) |
From: Mark H. <mha...@us...> - 2009-01-09 01:28:50
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16188/win32/src Modified Files: Tag: py3k PyTime.cpp Log Message: Fix recent regression working with datetime objects Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.19.2.3 retrieving revision 1.19.2.4 diff -C2 -d -r1.19.2.3 -r1.19.2.4 *** PyTime.cpp 8 Jan 2009 03:45:50 -0000 1.19.2.3 --- PyTime.cpp 9 Jan 2009 01:28:43 -0000 1.19.2.4 *************** *** 143,147 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 157,161 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 170,174 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 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; --- 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; |
From: Mark H. <mha...@us...> - 2009-01-09 01:27:49
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16153/win32/src Modified Files: PyTime.cpp Log Message: Fix recent regression working with datetime objects Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PyTime.cpp 8 Jan 2009 02:56:17 -0000 1.23 --- PyTime.cpp 9 Jan 2009 01:27:44 -0000 1.24 *************** *** 143,147 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 157,161 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 170,174 **** PyObject *newref = NULL; BOOL rc; ! if (!PyWinTime_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; *************** *** 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; --- 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; |
From: Mark H. <mha...@us...> - 2009-01-09 01:26:32
|
Update of /cvsroot/pywin32/pywin32/com/win32com/servers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16048/com/win32com/servers Modified Files: Tag: py3k test_pycomtest.py Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: test_pycomtest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/servers/test_pycomtest.py,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** test_pycomtest.py 7 Feb 2007 23:12:31 -0000 1.12 --- test_pycomtest.py 9 Jan 2009 01:26:19 -0000 1.12.2.1 *************** *** 77,80 **** --- 77,83 ---- return len(ints) + def SetBinSafeArray(self, buf): + return len(buf) + def SetVarArgs(self, *args): raise COMException(hresult=winerror.E_NOTIMPL) |
From: Mark H. <mha...@us...> - 2009-01-09 01:26:31
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16048/com/win32com/test Modified Files: Tag: py3k testPyComTest.py Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.32.2.8 retrieving revision 1.32.2.9 diff -C2 -d -r1.32.2.8 -r1.32.2.9 *** testPyComTest.py 5 Jan 2009 12:51:27 -0000 1.32.2.8 --- testPyComTest.py 9 Jan 2009 01:26:19 -0000 1.32.2.9 *************** *** 9,12 **** --- 9,13 ---- import win32com from win32com.test.util import RegisterPythonServer + from pywin32_testutil import str2memory importMsg = "**** PyCOMTest is not installed ***\n PyCOMTest is a Python test specific COM client and server.\n It is likely this server is not installed on this machine\n To install the server, you must get the win32com sources\n and build it using MS Visual C++" *************** *** 263,266 **** --- 264,272 ---- TestApplyResult(o.SetVariantSafeArray, (l,), len(l)) TestApplyResult(o.SetIntSafeArray, (l,), len(l)) + # check we can pass ints as a VT_UI1 + TestApplyResult(o.SetBinSafeArray, (l,), len(l)) + # and binary + TestApplyResult(o.SetBinSafeArray, (str2memory('foo\0bar'),), 7) + l=[] TestApplyResult(o.SetVariantSafeArray, (l,), len(l)) |
From: Mark H. <mha...@us...> - 2009-01-09 01:26:26
|
Update of /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16048/com/TestSources/PyCOMTest Modified Files: Tag: py3k PyCOMImpl.cpp PyCOMImpl.h PyCOMTest.idl Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: PyCOMTest.idl =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.idl,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -C2 -d -r1.19 -r1.19.2.1 *** PyCOMTest.idl 1 Jul 2008 00:07:58 -0000 1.19 --- PyCOMTest.idl 9 Jan 2009 01:26:19 -0000 1.19.2.1 *************** *** 205,208 **** --- 205,209 ---- // Test Safe arrays - simple, then alias, enum + HRESULT SetBinSafeArray([in] SAFEARRAY(unsigned char) buf, [out, retval]int *resultSize); HRESULT SetIntSafeArray([in] SAFEARRAY(int) ints, [out, retval]int *resultSize); HRESULT SetVariantSafeArray([in] SAFEARRAY(VARIANT) vars, [out, retval]int *resultSize); Index: PyCOMImpl.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.h,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -C2 -d -r1.16 -r1.16.2.1 *** PyCOMImpl.h 8 Apr 2008 11:51:26 -0000 1.16 --- PyCOMImpl.h 9 Jan 2009 01:26:19 -0000 1.16.2.1 *************** *** 71,74 **** --- 71,75 ---- STDMETHOD(TakeByRefTypedDispatch)(IPyCOMTest **inout); STDMETHOD(TakeByRefDispatch)(IDispatch **inout); + STDMETHOD(SetBinSafeArray)(SAFEARRAY* buf, int *retSize); STDMETHOD(SetIntSafeArray)(SAFEARRAY* ints, int *retSize); STDMETHOD(SetVariantSafeArray)(SAFEARRAY* vars, int *retSize); Index: PyCOMImpl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.cpp,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -C2 -d -r1.18 -r1.18.2.1 *** PyCOMImpl.cpp 8 Apr 2008 11:51:26 -0000 1.18 --- PyCOMImpl.cpp 9 Jan 2009 01:26:19 -0000 1.18.2.1 *************** *** 235,238 **** --- 235,254 ---- } + STDMETHODIMP CPyCOMTest::SetBinSafeArray(SAFEARRAY* buf, int *resultSize) + { + UINT cDims = SafeArrayGetDim(buf); + *resultSize = 0; + long ub=0, lb=0; + if (cDims) { + SafeArrayGetUBound(buf, 1, &ub); + SafeArrayGetLBound(buf, 1, &lb); + *resultSize = ub - lb + 1; + } + TCHAR dbgbuf[256]; + wsprintf(dbgbuf, _T("Have binary SafeArray with %d dims and size %d\n"), cDims, *resultSize); + OutputDebugString(dbgbuf); + return S_OK; + } + STDMETHODIMP CPyCOMTest::SetIntSafeArray(SAFEARRAY* ints, int *resultSize) { |
From: Mark H. <mha...@us...> - 2009-01-09 01:25:07
|
Update of /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15938/com/TestSources/PyCOMTest Modified Files: PyCOMImpl.cpp PyCOMImpl.h PyCOMTest.idl Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: PyCOMTest.idl =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.idl,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyCOMTest.idl 1 Jul 2008 00:07:58 -0000 1.19 --- PyCOMTest.idl 9 Jan 2009 01:24:54 -0000 1.20 *************** *** 205,208 **** --- 205,209 ---- // Test Safe arrays - simple, then alias, enum + HRESULT SetBinSafeArray([in] SAFEARRAY(unsigned char) buf, [out, retval]int *resultSize); HRESULT SetIntSafeArray([in] SAFEARRAY(int) ints, [out, retval]int *resultSize); HRESULT SetVariantSafeArray([in] SAFEARRAY(VARIANT) vars, [out, retval]int *resultSize); Index: PyCOMImpl.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyCOMImpl.h 8 Apr 2008 11:51:26 -0000 1.16 --- PyCOMImpl.h 9 Jan 2009 01:24:54 -0000 1.17 *************** *** 71,74 **** --- 71,75 ---- STDMETHOD(TakeByRefTypedDispatch)(IPyCOMTest **inout); STDMETHOD(TakeByRefDispatch)(IDispatch **inout); + STDMETHOD(SetBinSafeArray)(SAFEARRAY* buf, int *retSize); STDMETHOD(SetIntSafeArray)(SAFEARRAY* ints, int *retSize); STDMETHOD(SetVariantSafeArray)(SAFEARRAY* vars, int *retSize); Index: PyCOMImpl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyCOMImpl.cpp 8 Apr 2008 11:51:26 -0000 1.18 --- PyCOMImpl.cpp 9 Jan 2009 01:24:54 -0000 1.19 *************** *** 235,238 **** --- 235,254 ---- } + STDMETHODIMP CPyCOMTest::SetBinSafeArray(SAFEARRAY* buf, int *resultSize) + { + UINT cDims = SafeArrayGetDim(buf); + *resultSize = 0; + long ub=0, lb=0; + if (cDims) { + SafeArrayGetUBound(buf, 1, &ub); + SafeArrayGetLBound(buf, 1, &lb); + *resultSize = ub - lb + 1; + } + TCHAR dbgbuf[256]; + wsprintf(dbgbuf, _T("Have binary SafeArray with %d dims and size %d\n"), cDims, *resultSize); + OutputDebugString(dbgbuf); + return S_OK; + } + STDMETHODIMP CPyCOMTest::SetIntSafeArray(SAFEARRAY* ints, int *resultSize) { |
From: Mark H. <mha...@us...> - 2009-01-09 01:25:05
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15938/com/win32com/test Modified Files: testPyComTest.py Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** testPyComTest.py 4 Jan 2009 22:35:44 -0000 1.42 --- testPyComTest.py 9 Jan 2009 01:24:54 -0000 1.43 *************** *** 9,12 **** --- 9,13 ---- import win32com from win32com.test.util import RegisterPythonServer + from pywin32_testutil import str2memory importMsg = "**** PyCOMTest is not installed ***\n PyCOMTest is a Python test specific COM client and server.\n It is likely this server is not installed on this machine\n To install the server, you must get the win32com sources\n and build it using MS Visual C++" *************** *** 263,266 **** --- 264,272 ---- TestApplyResult(o.SetVariantSafeArray, (l,), len(l)) TestApplyResult(o.SetIntSafeArray, (l,), len(l)) + # check we can pass ints as a VT_UI1 + TestApplyResult(o.SetBinSafeArray, (l,), len(l)) + # and binary + TestApplyResult(o.SetBinSafeArray, (str2memory('foo\0bar'),), 7) + l=[] TestApplyResult(o.SetVariantSafeArray, (l,), len(l)) |
From: Mark H. <mha...@us...> - 2009-01-09 01:25:01
|
Update of /cvsroot/pywin32/pywin32/com/win32com/servers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15938/com/win32com/servers Modified Files: test_pycomtest.py Log Message: Explicit tests for VT_UI1 safe arrays being passed buffers and integers Index: test_pycomtest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/servers/test_pycomtest.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_pycomtest.py 7 Feb 2007 23:12:31 -0000 1.12 --- test_pycomtest.py 9 Jan 2009 01:24:54 -0000 1.13 *************** *** 77,80 **** --- 77,83 ---- return len(ints) + def SetBinSafeArray(self, buf): + return len(buf) + def SetVarArgs(self, *args): raise COMException(hresult=winerror.E_NOTIMPL) |
From: Mark H. <mha...@us...> - 2009-01-09 00:30:31
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10146 Modified Files: util.py Log Message: fix variable name Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/util.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** util.py 7 Jan 2009 05:59:56 -0000 1.18 --- util.py 9 Jan 2009 00:30:23 -0000 1.19 *************** *** 223,226 **** def testmain(*args, **kw): ! pywin32_testutil.testmain(*args, **new_kw) CheckClean() --- 223,226 ---- def testmain(*args, **kw): ! pywin32_testutil.testmain(*args, **kw) CheckClean() |
From: Mark H. <mha...@us...> - 2009-01-08 22:35:56
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28488/com/win32com/src Modified Files: PythonCOM.cpp Log Message: PyErr_WarnEx doesn't exist in 2.4 and earlier Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** PythonCOM.cpp 8 Jan 2009 02:45:31 -0000 1.56 --- PythonCOM.cpp 8 Jan 2009 22:35:50 -0000 1.57 *************** *** 18,21 **** --- 18,23 ---- #include "PyComTypeObjects.h" #include "OleAcc.h" // for ObjectFromLresult proto... + #include "pyerrors.h" // for PyErr_Warn in 2.5 and earlier... + extern int PyCom_RegisterCoreIIDs(PyObject *dict); *************** *** 744,748 **** 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); } --- 746,750 ---- static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "MakeIID is deprecated - please use pywintypes.IID() instead."); return PyWinMethod_NewIID(self, args); } *************** *** 751,755 **** 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); } --- 753,757 ---- static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "MakeTime is deprecated - please use pywintypes.Time() instead."); return PyWinMethod_NewTime(self, args); } |
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27228/Pythonwin Modified Files: ddeconv.cpp ddeitem.cpp ddeserver.cpp ddetopic.cpp dllmain.cpp pythonpsheet.cpp win32RichEdit.cpp win32RichEditDocTemplate.cpp win32app.cpp win32assoc.cpp win32assoc.h win32bitmap.cpp win32brush.cpp win32cmd.cpp win32cmd.h win32cmdui.cpp win32cmdui.h win32control.cpp win32control.h win32ctledit.cpp win32ctrlList.cpp win32ctrlRichEdit.cpp win32ctrlTree.cpp win32dc.cpp win32dc.h win32dlg.cpp win32dlg.h win32dlgbar.cpp win32dll.cpp win32dll.h win32doc.cpp win32font.cpp win32gdi.cpp win32gdi.h win32hl.h win32menu.cpp win32notify.cpp win32oleDlgInsert.cpp win32oleDlgs.cpp win32pen.cpp win32prinfo.cpp win32prinfo.h win32prop.cpp win32prop.h win32rgn.cpp win32splitter.cpp win32template.cpp win32thread.cpp win32toolbar.cpp win32toolbar.h win32tooltip.cpp win32ui.h win32uimodule.cpp win32uioleClientItem.cpp win32uioledoc.cpp win32util.cpp win32view.cpp win32virt.cpp win32win.cpp win32win.h Log Message: Merge from py3k branch: * Roger's work to move to getattr and using builtin Python inheritance. * Move to using weak-references to store associations between MFC objects and Python objects. * Lots of memory leaks fixed Index: win32ctledit.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctledit.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32ctledit.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- win32ctledit.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 424,427 **** --- 424,428 ---- RUNTIME_CLASS(CEdit), sizeof(PyCEdit), + PYOBJ_OFFSET(PyCEdit), PyCEdit_methods, GET_PY_CTOR(PyCEdit)); Index: win32app.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32app.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32app.cpp 13 Nov 2008 04:04:50 -0000 1.7 --- win32app.cpp 8 Jan 2009 22:11:52 -0000 1.8 *************** *** 416,419 **** --- 416,420 ---- RUNTIME_CLASS(CWinApp), sizeof(PyCWinApp), + PYOBJ_OFFSET(PyCWinApp), PyCWinApp_methods, GET_PY_CTOR(PyCWinApp) ); Index: win32win.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** win32win.cpp 5 Jan 2009 10:47:28 -0000 1.23 --- win32win.cpp 8 Jan 2009 22:11:52 -0000 1.24 *************** *** 70,75 **** BOOL Python_check_message(const MSG *msg) // TRUE if fully processed. { ! ! ui_assoc_object *pObj; PyObject *method; CWnd *pWnd = bInFatalShutdown ? NULL : CWnd::FromHandlePermanent(msg->hwnd); --- 70,75 ---- BOOL Python_check_message(const MSG *msg) // TRUE if fully processed. { ! BOOL ret; ! ui_assoc_object *pObj = NULL; PyObject *method; CWnd *pWnd = bInFatalShutdown ? NULL : CWnd::FromHandlePermanent(msg->hwnd); *************** *** 77,81 **** CEnterLeavePython _celp; if (pWnd && ! (pObj=ui_assoc_object::GetPyObject(pWnd)) && pObj->is_uiobject( &PyCWnd::type ) && ((PyCWnd *)pObj)->pMessageHookList && --- 77,81 ---- CEnterLeavePython _celp; if (pWnd && ! (pObj=ui_assoc_object::GetAssocObject(pWnd)) && pObj->is_uiobject( &PyCWnd::type ) && ((PyCWnd *)pObj)->pMessageHookList && *************** *** 87,93 **** // Our Python convention is TRUE means "pass it on" // CEnterLeavePython _celp; ! return Python_callback(method, msg)==0; ! } ! return FALSE; // dont want it. } --- 87,95 ---- // Our Python convention is TRUE means "pass it on" // CEnterLeavePython _celp; ! ret = Python_callback(method, msg)==0; ! } else ! ret = FALSE; // dont want it. ! Py_XDECREF(pObj); ! return ret; } *************** *** 95,104 **** { CEnterLeavePython _celp; ! ui_assoc_object *pObj; BOOL bPassOn = TRUE; CWnd *pWnd = msg->hwnd ? CWnd::FromHandlePermanent(msg->hwnd) : NULL; ! if (pWnd && (pObj=ui_assoc_object::GetPyObject(pWnd)) && pObj->is_uiobject( &PyCWnd::type )) bPassOn = ((PyCWnd*)pObj)->check_key_stroke(msg->wParam); return !bPassOn; } --- 97,107 ---- { CEnterLeavePython _celp; ! ui_assoc_object *pObj = NULL; BOOL bPassOn = TRUE; CWnd *pWnd = msg->hwnd ? CWnd::FromHandlePermanent(msg->hwnd) : NULL; ! if (pWnd && (pObj=ui_assoc_object::GetAssocObject(pWnd)) && pObj->is_uiobject( &PyCWnd::type )) bPassOn = ((PyCWnd*)pObj)->check_key_stroke(msg->wParam); + Py_XDECREF(pObj); return !bPassOn; } *************** *** 598,630 **** PyCWnd::~PyCWnd() { - DoKillAssoc(TRUE); - } - - BOOL PyCWnd::check_key_stroke(WPARAM ch) - { - PyObject *pythonObject; - BOOL bCallBase = TRUE; - if (obKeyStrokeHandler!= NULL) - bCallBase = Python_callback(obKeyStrokeHandler, ch); - - if (bCallBase && pKeyHookList && pKeyHookList->Lookup((WORD)ch, (void *&)pythonObject)) - bCallBase = Python_callback(pythonObject,ch); - return bCallBase; - } - - CWnd *PyCWnd::GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType) - { - // Damn it - only pass PyCWnd::type so the RTTI check wont fail - // for builtin controls. - return (CWnd *)GetGoodCppObject( self, &type ); - } - - void PyCWnd::DoKillAssoc( BOOL bDestructing /*= FALSE*/ ) - { free_hook_list(this,&pMessageHookList); free_hook_list(this,&pKeyHookList); Py_XDECREF(obKeyStrokeHandler); obKeyStrokeHandler = NULL; - PyCCmdTarget::DoKillAssoc(bDestructing); if (bManualDelete || bDidSubclass) { // Can't use GetWndPtr(this) as ob_type has been nuked. --- 601,608 ---- *************** *** 632,644 **** if (pWnd) { if (bDidSubclass) { - // pWnd->Detach(); pWnd->UnsubclassWindow(); bDidSubclass = FALSE; } - // DONT detach - bDidSubclass is only logic needed. - // if (pWnd->GetSafeHwnd()) { - // TRACE("Warning - DoKillAssoc detaching from existing window\n"); - // pWnd->Detach(); - // } if (bManualDelete) { // Release the lock while we destroy the object. --- 610,616 ---- *************** *** 651,654 **** --- 623,646 ---- } } + + BOOL PyCWnd::check_key_stroke(WPARAM ch) + { + PyObject *pythonObject; + BOOL bCallBase = TRUE; + if (obKeyStrokeHandler!= NULL) + bCallBase = Python_callback(obKeyStrokeHandler, ch); + + if (bCallBase && pKeyHookList && pKeyHookList->Lookup((WORD)ch, (void *&)pythonObject)) + bCallBase = Python_callback(pythonObject,ch); + return bCallBase; + } + + CWnd *PyCWnd::GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType) + { + // Damn it - only pass PyCWnd::type so the RTTI check wont fail + // for builtin controls. + return (CWnd *)GetGoodCppObject( self, &type ); + } + /*static*/ PyCWnd *PyCWnd::make( ui_type_CObject &makeType, CWnd *pSearch, HWND wnd /*=NULL*/ ) { *************** *** 2719,2724 **** 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, *************** *** 3195,3201 **** PyObject* ui_window_set_icon(PyObject* self, PyObject *args) { ! HICON hiconPrevIcon; BOOL bBigIcon = TRUE; ! if (!PyArg_ParseTuple(args, "ii:SetIcon", &hiconPrevIcon, &bBigIcon)) return NULL; CWnd *pWnd = GetWndPtr(self); --- 3187,3196 ---- PyObject* ui_window_set_icon(PyObject* self, PyObject *args) { ! PyObject *obiconprev; BOOL bBigIcon = TRUE; ! if (!PyArg_ParseTuple(args, "Oi:SetIcon", &obiconprev, &bBigIcon)) ! return NULL; ! HICON hiconprev; ! if (!PyWinObject_AsHANDLE(obiconprev, (HANDLE *)&hiconprev)) return NULL; CWnd *pWnd = GetWndPtr(self); *************** *** 3203,3207 **** return NULL; GUI_BGN_SAVE; ! HICON hiconRetVal = pWnd->SetIcon(hiconPrevIcon, bBigIcon); GUI_END_SAVE; return PyWinLong_FromHANDLE(hiconRetVal); --- 3198,3202 ---- return NULL; GUI_BGN_SAVE; ! HICON hiconRetVal = pWnd->SetIcon(hiconprev, bBigIcon); GUI_END_SAVE; return PyWinLong_FromHANDLE(hiconRetVal); *************** *** 3347,3350 **** --- 3342,3346 ---- RUNTIME_CLASS(CWnd), sizeof(PyCWnd), + PYOBJ_OFFSET(PyCWnd), PyCWnd_methods, GET_PY_CTOR(PyCWnd) ); *************** *** 3952,3955 **** --- 3948,3952 ---- RUNTIME_CLASS(CFrameWnd), sizeof(PyCFrameWnd), + PYOBJ_OFFSET(PyCFrameWnd), PyCFrameWnd_methods, GET_PY_CTOR(PyCFrameWnd)); *************** *** 4124,4127 **** --- 4121,4125 ---- RUNTIME_CLASS(CMDIFrameWnd), sizeof(PyCMDIFrameWnd), + PYOBJ_OFFSET(PyCMDIFrameWnd), PyCMDIFrameWnd_methods, GET_PY_CTOR(PyCMDIFrameWnd)); *************** *** 4310,4313 **** --- 4308,4312 ---- RUNTIME_CLASS(CMDIChildWnd), sizeof(PyCMDIChildWnd), + PYOBJ_OFFSET(PyCMDIChildWnd), PyCMDIChildWnd_methods, GET_PY_CTOR(PyCMDIChildWnd)); Index: win32assoc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32assoc.cpp 28 Dec 2008 10:10:02 -0000 1.11 --- win32assoc.cpp 8 Jan 2009 22:11:52 -0000 1.12 *************** *** 15,18 **** --- 15,24 ---- #include "stdafx.h" + #ifdef DEBUG + #define ASSERT_GIL_HELD {PyGILState_STATE s=PyGILState_Ensure();ASSERT(s==PyGILState_LOCKED);PyGILState_Release(s);} + #else + #define ASSERT_GIL_HELD + #endif + CAssocManager ui_assoc_object::handleMgr; *************** *** 20,24 **** { lastLookup = NULL; ! lastObject = NULL; #ifdef _DEBUG cacheLookups = cacheHits = 0; --- 26,30 ---- { lastLookup = NULL; ! lastObjectWeakRef = NULL; #ifdef _DEBUG cacheLookups = cacheHits = 0; *************** *** 48,85 **** ASSERT_VALID(&map); TRACE("CAssocManager cleaning up %d objects\n", map.GetCount()); ! m_critsec.Lock(); for(pos=map.GetStartPosition();pos;) { map.GetNextAssoc(pos, (void *&)assoc, (void *&)ob); ! ob->cleanup(); ! // not sure if I should do this!! ! //PyMem_DEL(ob); } - m_critsec.Unlock(); } ! void CAssocManager::Assoc(void *handle, ui_assoc_object *object, void *oldHandle) { ! m_critsec.Lock(); ! if (oldHandle) { ! // if window previously closed, this may fail when the Python object ! // destructs - but this is not a problem. ! map.RemoveKey(oldHandle); ! if (oldHandle==lastLookup) ! lastLookup = 0; // set cache invalid. } - if (handle) - map.SetAt(handle, object); - if (handle==lastLookup) - lastObject = object; - m_critsec.Unlock(); } // // CAssocManager::GetAssocObject ! // ! ui_assoc_object *CAssocManager::GetAssocObject(const void * handle) { if (handle==NULL) return NULL; // no possible association for NULL! ! ui_assoc_object *ret; ! m_critsec.Lock(); #ifdef _DEBUG cacheLookups++; --- 54,121 ---- ASSERT_VALID(&map); TRACE("CAssocManager cleaning up %d objects\n", map.GetCount()); ! CEnterLeavePython _celp; for(pos=map.GetStartPosition();pos;) { map.GetNextAssoc(pos, (void *&)assoc, (void *&)ob); ! RemoveAssoc(assoc); } } ! ! void CAssocManager::RemoveAssoc(void *handle) { ! // nuke any existing items. ! PyObject *weakref; ! if (map.Lookup(handle, (void *&)weakref)) { ! PyObject *ob = PyWeakref_GetObject(weakref); ! map.RemoveKey(handle); ! if (ob != Py_None) ! // The object isn't necessarily dead (ie, its refcount may ! // not be about to hit zero), but its 'dead' from our POV, so ! // let it free any MFC etc resources the object owns. ! // XXX - this kinda sucks - just relying on the object ! // destructor *should* be OK... ! ((ui_assoc_object *)ob)->cleanup(); ! Py_DECREF(weakref); ! } ! lastObjectWeakRef = 0; ! lastLookup = 0; // set cache invalid. ! } ! ! void CAssocManager::Assoc(void *handle, ui_assoc_object *object) ! { ! ASSERT_GIL_HELD; // we rely on the GIL to serialize access to our map... ! ASSERT(handle); ! #ifdef DEBUG ! // overwriting an existing entry probably means we are failing to ! // detect the death of the old object and its address has been reused. ! if (object) { // might just be nuking ours, so we expect to find outself! ! PyObject *existing_weakref; ! if (map.Lookup(handle, (void *&)existing_weakref)) { ! TRACE("CAssocManager::Assoc overwriting existing assoc\n"); ! DebugBreak(); ! } ! } ! #endif ! RemoveAssoc(handle); ! if (object) { ! PyObject *weakref = PyWeakref_NewRef(object, NULL); ! if (weakref) ! // reference owned by the map. ! map.SetAt(handle, weakref); ! else { ! TRACE("Failed to create weakref\n"); ! gui_print_error(); ! DebugBreak(); ! } } } // // CAssocManager::GetAssocObject ! // Returns an object *with a new reference*. NULL is not an error return - it just means "no object" ! ui_assoc_object *CAssocManager::GetAssocObject(void * handle) { if (handle==NULL) return NULL; // no possible association for NULL! ! ASSERT_GIL_HELD; // we rely on the GIL to serialize access to our map... ! PyObject *weakref; #ifdef _DEBUG cacheLookups++; *************** *** 87,91 **** // implement a basic 1 item cache. if (lastLookup==handle) { ! ret = lastObject; #ifdef _DEBUG ++cacheHits; --- 123,127 ---- // implement a basic 1 item cache. if (lastLookup==handle) { ! weakref = lastObjectWeakRef; #ifdef _DEBUG ++cacheHits; *************** *** 93,102 **** } else { ! if (!map.Lookup((void *)handle, (void *&)ret)) ! ret = NULL; lastLookup = handle; ! lastObject = ret; } - m_critsec.Unlock(); return ret; } --- 129,157 ---- } else { ! if (!map.Lookup((void *)handle, (void *&)weakref)) ! weakref = NULL; lastLookup = handle; ! lastObjectWeakRef = weakref; ! } ! if (weakref==NULL) ! return NULL; ! // convert the weakref object into a real object. ! PyObject *ob = PyWeakref_GetObject(weakref); ! if (ob == NULL) { ! // an error - but a NULL return from us just means "no assoc" ! // so print the error and ignore it, treating it as if the ! // weak-ref target has died. ! gui_print_error(); ! ob = Py_None; ! } ! ui_assoc_object *ret; ! if (ob == Py_None) { ! // weak-ref target has died. Remove it from the map. ! Assoc(handle, NULL); ! ret = NULL; ! } else { ! ret = (ui_assoc_object *)ob; ! Py_INCREF(ret); } return ret; } *************** *** 191,194 **** --- 246,250 ---- &ui_base_class::type, sizeof(ui_assoc_object), + PYOBJ_OFFSET(ui_assoc_object), PyAssocObject_methods, NULL); *************** *** 201,211 **** ui_assoc_object::~ui_assoc_object() { - KillAssoc(); - } - - // handle is invalid - therefore release all refs I am holding for it. - // ASSUMES WE HOLD THE PYTHON LOCK as for all Python object destruction. - void ui_assoc_object::KillAssoc() - { #ifdef TRACE_ASSOC CString rep = repr(); --- 257,260 ---- *************** *** 213,248 **** TRACE("Destroying association with %p and %s",this,szRep); #endif ! // note that _any_ of these may cause this to be deleted, as the reference ! // count may drop to zero. If any one dies, and later ones will fail. Therefore ! // I incref first, and decref at the end. ! // Note that this _always_ recurses when this happens as the destructor also ! // calls us to cleanup. Forcing an INCREF/DODECREF in that situation causes death ! // by recursion, as each dec back to zero causes a delete. ! BOOL bDestructing = ob_refcnt==0; ! if (!bDestructing) ! Py_INCREF(this); ! DoKillAssoc(bDestructing); // kill all map entries, etc. ! SetAssocInvalid(); // let child do whatever to detect ! if (!bDestructing) ! DODECREF(this); ! } ! // the virtual version... ! // ASSUMES WE HOLD THE PYTHON LOCK as for all Python object destruction. ! void ui_assoc_object::DoKillAssoc( BOOL bDestructing /*= FALSE*/ ) ! { ! // In Python debug builds, this can get recursive - ! // Python temporarily increments the refcount of the dieing ! // object - this object death will attempt to use the dieing object. ! PyObject *vi = virtualInst; ! virtualInst = NULL; ! Py_XDECREF(vi); // virtuals.DeleteAll(); ! handleMgr.Assoc(0,this,assoc); ! } ! ! // return an object, given an association, if we have one. ! /* static */ ui_assoc_object *ui_assoc_object::GetPyObject(void *search) ! { ! return (ui_assoc_object *)handleMgr.GetAssocObject(search); } --- 262,271 ---- TRACE("Destroying association with %p and %s",this,szRep); #endif ! Py_CLEAR(virtualInst); // virtuals.DeleteAll(); ! if (assoc) { ! handleMgr.Assoc(assoc, 0); ! SetAssocInvalid(); // let child do whatever to detect ! } } *************** *** 262,265 **** --- 285,289 ---- { ASSERT(search); // really only a C++ problem. + CEnterLeavePython _celp; ui_assoc_object* ret=NULL; if (!skipLookup) *************** *** 272,276 **** return NULL; } - DOINCREF( ret ); return ret; } --- 296,299 ---- *************** *** 283,288 **** TRACE_ASSOC (" Associating 0x%x with 0x%x", search, ret); #endif ! // if I have an existing handle, remove it. ! handleMgr.Assoc(search, ret,NULL); ret->assoc = search; } --- 306,310 ---- TRACE_ASSOC (" Associating 0x%x with 0x%x", search, ret); #endif ! handleMgr.Assoc(search, ret); ret->assoc = search; } *************** *** 338,341 **** --- 360,364 ---- RUNTIME_CLASS(CObject), sizeof(ui_assoc_CObject), + PYOBJ_OFFSET(ui_assoc_CObject), PyAssocCObject_methods, NULL); *************** *** 351,355 **** bManualDelete = FALSE; CObject *pO = (CObject *)GetGoodCppObject(&type); // get pointer before killing it. ! KillAssoc(); // stop recursion - disassociate now. if (!pO) PyErr_Clear(); --- 374,378 ---- bManualDelete = FALSE; CObject *pO = (CObject *)GetGoodCppObject(&type); // get pointer before killing it. ! ASSERT(!PyErr_Occurred()); // PyErr_Clear() is bogus????? if (!pO) PyErr_Clear(); Index: win32ctrlRichEdit.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlRichEdit.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32ctrlRichEdit.cpp 13 Nov 2008 04:04:50 -0000 1.5 --- win32ctrlRichEdit.cpp 8 Jan 2009 22:11:52 -0000 1.6 *************** *** 866,884 **** return NULL; CHECK_NO_ARGS2(args,GetSelText); ! long start=0, end=0; GUI_BGN_SAVE; ! pEdit->GetSel(start, end); GUI_END_SAVE; ! PyObject *ret; ! if (end-start) { ! ret = PyString_FromStringAndSize(NULL, end-start); ! char *buf = PyString_AsString(ret); ! GUI_BGN_SAVE; ! pEdit->GetSelText(buf); ! GUI_END_SAVE; ! } ! else ! ret = PyString_FromStringAndSize("", 0); ! return ret; } --- 866,874 ---- return NULL; CHECK_NO_ARGS2(args,GetSelText); ! CString str; GUI_BGN_SAVE; ! str = pEdit->GetSelText(); GUI_END_SAVE; ! return PyWinObject_FromTCHAR(str); } *************** *** 924,927 **** }; ! PyCCtrlView_Type PyCRichEditCtrl::type("PyCRichEditCtrl",&ui_control_object::type, &PyCRichEditCtrl::type, RUNTIME_CLASS(CRichEditCtrl), sizeof(PyCRichEditCtrl), PyCRichEditCtrl_methods, GET_PY_CTOR(PyCRichEditCtrl)); --- 914,924 ---- }; ! PyCCtrlView_Type PyCRichEditCtrl::type("PyCRichEditCtrl", ! &ui_control_object::type, ! &PyCRichEditCtrl::type, ! RUNTIME_CLASS(CRichEditCtrl), ! sizeof(PyCRichEditCtrl), ! PYOBJ_OFFSET(PyCRichEditCtrl), ! PyCRichEditCtrl_methods, ! GET_PY_CTOR(PyCRichEditCtrl)); Index: win32view.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32view.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32view.cpp 13 Nov 2008 04:04:50 -0000 1.5 --- win32view.cpp 8 Jan 2009 22:11:52 -0000 1.6 *************** *** 410,413 **** --- 410,414 ---- RUNTIME_CLASS(CView), sizeof(PyCView), + PYOBJ_OFFSET(PyCView), PyCView_methods, NULL); *************** *** 626,629 **** --- 627,631 ---- RUNTIME_CLASS(CScrollView), sizeof(PyCScrollView), + PYOBJ_OFFSET(PyCScrollView), PyCScrollView_methods, GET_PY_CTOR(PyCScrollView)); *************** *** 684,704 **** RUNTIME_CLASS(CCtrlView), sizeof(PyCCtrlView), PyCCtrlView_methods, GET_PY_CTOR(PyCCtrlView)); - /* Implement an psuedo-inheritance for ControlView */ - PyObject * - PyCCtrlView::getattr(char *name) - { - // implement inheritance. - PyObject *retMethod = PyCView::getattr(name); - if (!retMethod) { - PyErr_Clear(); - PyCCtrlView_Type *thisType = (PyCCtrlView_Type *)ob_type; - if (thisType) - retMethod = Py_FindMethod(thisType->control->methods, (PyObject *)this, name); - } - return retMethod; - } ///////////////////////////////////////////////////////////////////// --- 686,693 ---- RUNTIME_CLASS(CCtrlView), sizeof(PyCCtrlView), + PYOBJ_OFFSET(PyCCtrlView), PyCCtrlView_methods, GET_PY_CTOR(PyCCtrlView)); ///////////////////////////////////////////////////////////////////// *************** *** 940,944 **** // @base PyCEditView|PyCCtrlView ! PyCCtrlView_Type PyCEditView::type("PyCEditView", &PyCCtrlView::type, &PyCEdit::type, RUNTIME_CLASS(CEditView), sizeof(PyCEditView), ui_edit_window_methods, GET_PY_CTOR(PyCEditView)); ///////////////////////////////////////////////////////////////////// --- 929,940 ---- // @base PyCEditView|PyCCtrlView ! PyCCtrlView_Type PyCEditView::type("PyCEditView", ! &PyCCtrlView::type, ! &PyCEdit::type, ! RUNTIME_CLASS(CEditView), ! sizeof(PyCEditView), ! PYOBJ_OFFSET(PyCEditView), ! ui_edit_window_methods, ! GET_PY_CTOR(PyCEditView)); ///////////////////////////////////////////////////////////////////// *************** *** 1021,1024 **** --- 1017,1021 ---- RUNTIME_CLASS(CListView), sizeof(PyCListView), + PYOBJ_OFFSET(PyCListView), ui_list_view_methods, GET_PY_CTOR(PyCListView)); *************** *** 1102,1105 **** --- 1099,1103 ---- RUNTIME_CLASS(CTreeView), sizeof(PyCTreeView), + PYOBJ_OFFSET(PyCTreeView), ui_tree_view_methods, GET_PY_CTOR(PyCTreeView)); *************** *** 1163,1166 **** --- 1161,1165 ---- RUNTIME_CLASS(CFormView), sizeof(PyCFormView), + PYOBJ_OFFSET(PyCFormView), PyCFormView_methods, GET_PY_CTOR(PyCFormView)); Index: win32rgn.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32rgn.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32rgn.cpp 1 Jul 2002 15:09:40 -0000 1.2 --- win32rgn.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 180,183 **** --- 180,184 ---- RUNTIME_CLASS(CRgn), sizeof(PyCRgn), + PYOBJ_OFFSET(PyCRgn), PyCRgn_methods, GET_PY_CTOR(PyCRgn)); Index: win32dlg.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlg.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32dlg.cpp 4 Dec 2008 00:17:13 -0000 1.12 --- win32dlg.cpp 8 Jan 2009 22:11:52 -0000 1.13 *************** *** 175,207 **** } - PyCWnd::DoKillAssoc(TRUE); ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid ! Py_XDECREF(ddlist); ! Py_XDECREF(dddict); ! } ! void PyCDialog::DoKillAssoc(BOOL bDestructing /*=FALSE*/ ) ! { ! // we can not have the pointer deleted at window destruction time // for a dialog (as MFC still needs it after the dialog has completed BOOL bManDeleteSave = bManualDelete; ! if (!bDestructing) ! bManualDelete = FALSE; ! PyCWnd::DoKillAssoc(bDestructing); ! if (!bDestructing) ! bManualDelete = bManDeleteSave; } PyObject * ! PyCDialog::getattr(char *name) { if (strcmp(name,"data")==0) { Py_INCREF(dddict); return dddict; ! } ! else if (strcmp(name,"datalist")==0) { Py_INCREF(ddlist); return ddlist; ! } ! else ! return ui_base_class::getattr(name); } --- 175,198 ---- } ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid ! Py_XDECREF(ddlist); // we can not have the pointer deleted at window destruction time // for a dialog (as MFC still needs it after the dialog has completed BOOL bManDeleteSave = bManualDelete; ! Py_XDECREF(dddict); } + PyObject * ! PyCDialog::getattro(PyObject *obname) { + char *name=PYWIN_ATTR_CONVERT(obname); if (strcmp(name,"data")==0) { Py_INCREF(dddict); return dddict; ! } ! if (strcmp(name,"datalist")==0) { Py_INCREF(ddlist); return ddlist; ! } ! return PyObject_GenericGetAttr(this, obname); } *************** *** 216,219 **** --- 207,211 ---- static PyObject *do_exchange_edit( int id, int index, char *type, PyObject *oldVal, PyObject *o1, PyObject *o2, CDataExchange *pDX ) { + // Note use of funky exception handlers to ensure thread-state remains correct even when MFC exception is thrown. PyObject *newOb; switch (type[0]) { *************** *** 222,228 **** if (oldVal) intVal = (int)PyInt_AsLong(oldVal); ! GUI_BGN_SAVE; ! DDX_Text(pDX, id, intVal); ! GUI_END_SAVE; if (o1 && o2) { if (PyInt_Check(o1) && PyInt_Check(o2)) --- 214,229 ---- if (oldVal) intVal = (int)PyInt_AsLong(oldVal); ! PyThreadState *_save = PyEval_SaveThread(); ! TRY ! { ! DDX_Text(pDX, id, intVal); ! PyEval_RestoreThread(_save); ! } ! CATCH_ALL(e) ! { ! PyEval_RestoreThread(_save); ! THROW(e); ! } ! END_CATCH_ALL if (o1 && o2) { if (PyInt_Check(o1) && PyInt_Check(o2)) *************** *** 245,251 **** csVal=_T(""); } ! GUI_BGN_SAVE; ! DDX_Text(pDX, id, csVal); ! GUI_END_SAVE; if (o1 && o2) { if (PyInt_Check(o1) && o2==NULL) --- 246,261 ---- csVal=_T(""); } ! PyThreadState *_save = PyEval_SaveThread(); ! TRY ! { ! DDX_Text(pDX, id, csVal); ! PyEval_RestoreThread(_save); ! } ! CATCH_ALL(e) ! { ! PyEval_RestoreThread(_save); ! THROW(e); ! } ! END_CATCH_ALL if (o1 && o2) { if (PyInt_Check(o1) && o2==NULL) *************** *** 400,404 **** { CEnterLeavePython _celp; ! PyCDialog *dob = (PyCDialog *) ui_assoc_object::GetPyObject(pDlg); if (!dob) { TRACE("do_exchange called on dialog with no Python object!\n"); --- 410,414 ---- { CEnterLeavePython _celp; ! PyCDialog *dob = (PyCDialog *) ui_assoc_object::GetAssocObject(pDlg); if (!dob) { TRACE("do_exchange called on dialog with no Python object!\n"); *************** *** 447,450 **** --- 457,461 ---- if (PyErr_Occurred()) gui_print_error(); + Py_DECREF(dob); } *************** *** 732,735 **** --- 743,747 ---- RUNTIME_CLASS(CDialog), sizeof(PyCDialog), + PYOBJ_OFFSET(PyCDialog), ui_dialog_methods, GET_PY_CTOR(PyCDialog)); *************** *** 744,747 **** --- 756,760 ---- NULL, // CCommonDialog doesnt have RTTI??? sizeof(PyCCommonDialog), + PYOBJ_OFFSET(PyCCommonDialog), ui_common_dialog_methods, NULL); *************** *** 966,969 **** --- 979,983 ---- RUNTIME_CLASS(CFileDialog), sizeof(PyCFileDialog), + PYOBJ_OFFSET(PyCFileDialog), ui_file_dialog_methods, GET_PY_CTOR(PyCFileDialog)); *************** *** 1175,1178 **** --- 1189,1193 ---- RUNTIME_CLASS(CFontDialog), sizeof(PyCFontDialog), + PYOBJ_OFFSET(PyCFontDialog), ui_font_dialog_methods, GET_PY_CTOR(PyCFontDialog)); *************** *** 1332,1335 **** --- 1347,1351 ---- RUNTIME_CLASS(CColorDialog), sizeof(PyCColorDialog), + PYOBJ_OFFSET(PyCColorDialog), ui_color_dialog_methods, GET_PY_CTOR(PyCColorDialog)); *************** *** 1436,1439 **** --- 1452,1456 ---- RUNTIME_CLASS(CPrintDialog), sizeof(PyCPrintDialog), + PYOBJ_OFFSET(PyCPrintDialog), ui_print_dialog_methods, GET_PY_CTOR(PyCPrintDialog)); Index: win32ctrlTree.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlTree.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32ctrlTree.cpp 13 Nov 2008 04:04:50 -0000 1.7 --- win32ctrlTree.cpp 8 Jan 2009 22:11:52 -0000 1.8 *************** *** 857,860 **** --- 857,861 ---- RUNTIME_CLASS(CTreeCtrl), sizeof(PyCTreeCtrl), + PYOBJ_OFFSET(PyCTreeCtrl), PyCTreeCtrl_methods, GET_PY_CTOR(PyCTreeCtrl)); Index: win32virt.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32virt.cpp 6 Dec 2008 00:35:20 -0000 1.8 --- win32virt.cpp 8 Jan 2009 22:11:52 -0000 1.9 *************** *** 19,23 **** extern BOOL bInFatalShutdown; ! CVirtualHelper::CVirtualHelper(const char *iname, const void *iassoc, EnumVirtualErrorHandling veh/* = VEH_PRINT_ERROR */) { handler=NULL; --- 19,23 ---- extern BOOL bInFatalShutdown; ! CVirtualHelper::CVirtualHelper(const char *iname, void *iassoc, EnumVirtualErrorHandling veh/* = VEH_PRINT_ERROR */) { handler=NULL; *************** *** 26,35 **** csHandlerName = iname; vehErrorHandling = veh; ! ui_assoc_object *py_bob = ui_assoc_object::handleMgr.GetAssocObject( iassoc ); ! if (bInFatalShutdown || py_bob==NULL) return; CEnterLeavePython _celp; if (!py_bob->is_uiobject( &ui_assoc_object::type)) { TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n"); return; } --- 26,38 ---- csHandlerName = iname; vehErrorHandling = veh; ! if (bInFatalShutdown) return; CEnterLeavePython _celp; + ui_assoc_object *py_bob = ui_assoc_object::handleMgr.GetAssocObject( iassoc ); + if (py_bob==NULL) + return; if (!py_bob->is_uiobject( &ui_assoc_object::type)) { TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n"); + Py_DECREF(py_bob); return; } *************** *** 53,58 **** } py_ob = py_bob; ! Py_INCREF(py_ob); } CVirtualHelper::~CVirtualHelper() { --- 56,62 ---- } py_ob = py_bob; ! // reference on 'py_bob' now owned by 'py_ob' } + CVirtualHelper::~CVirtualHelper() { Index: win32splitter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32splitter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32splitter.cpp 13 Nov 2008 04:04:50 -0000 1.3 --- win32splitter.cpp 8 Jan 2009 22:11:52 -0000 1.4 *************** *** 246,249 **** --- 246,250 ---- RUNTIME_CLASS(CSplitterWnd), sizeof(PyCSplitterWnd), + PYOBJ_OFFSET(PyCSplitterWnd), ui_splitter_window_methods, GET_PY_CTOR(PyCSplitterWnd)); Index: ddeconv.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddeconv.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ddeconv.cpp 6 Dec 2008 00:34:06 -0000 1.3 --- ddeconv.cpp 8 Jan 2009 22:11:52 -0000 1.4 *************** *** 131,134 **** --- 131,135 ---- RUNTIME_CLASS(CDDEConv), sizeof(PyDDEConv), + PYOBJ_OFFSET(PyDDEConv), PyDDEConv_methods, GET_PY_CTOR(PyDDEConv)); Index: win32thread.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32thread.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32thread.cpp 13 Nov 2008 04:04:50 -0000 1.10 --- win32thread.cpp 8 Jan 2009 22:11:52 -0000 1.11 *************** *** 331,334 **** --- 331,335 ---- RUNTIME_CLASS(CWinThread), sizeof(PyCWinThread), + PYOBJ_OFFSET(PyCWinThread), PyCWinThread_methods, GET_PY_CTOR(PyCWinThread) ); Index: win32doc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32doc.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32doc.cpp 13 Nov 2008 04:04:50 -0000 1.6 --- win32doc.cpp 8 Jan 2009 22:11:52 -0000 1.7 *************** *** 443,446 **** --- 443,447 ---- RUNTIME_CLASS(CDocument), sizeof(PyCDocument), + PYOBJ_OFFSET(PyCDocument), ui_doc_methods, GET_PY_CTOR(PyCDocument) ); Index: win32prop.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prop.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32prop.cpp 13 Nov 2008 04:04:50 -0000 1.4 --- win32prop.cpp 8 Jan 2009 22:11:52 -0000 1.5 *************** *** 106,122 **** { } - /******** - TRACE("PropSheet object destructing\n"); - CPythonPropertySheet *pSheet = GetPythonPropSheet(this); - ASSERT(pSheet); - PyCWnd::DoKillAssoc(TRUE); - ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid - } - - void PyCPropertySheet::DoKillAssoc(BOOL bDestructing ) - { - return; - } - *************/ // @pymethod <o PyCPropertySheet>|win32ui|CreatePropertySheet|Creates a property sheet object. PyObject *PyCPropertySheet::create( PyObject *self, PyObject *args ) --- 106,109 ---- *************** *** 581,584 **** --- 568,572 ---- RUNTIME_CLASS(CPropertySheet), sizeof(PyCPropertySheet), + PYOBJ_OFFSET(PyCPropertySheet), ui_propsheet_methods, GET_PY_CTOR(PyCPropertySheet)); *************** *** 862,865 **** --- 850,854 ---- RUNTIME_CLASS(CPropertyPage), sizeof(PyCPropertyPage), + PYOBJ_OFFSET(PyCPropertyPage), ui_proppage_methods, GET_PY_CTOR(PyCPropertyPage)); *************** *** 938,941 **** --- 927,931 ---- RUNTIME_CLASS(CTabCtrl), sizeof(ui_tabctrl_object), + PYOBJ_OFFSET(ui_tabctrl_object), ui_tabctrl_methods, GET_PY_CTOR(ui_tabctrl_object)); Index: win32notify.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32notify.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32notify.cpp 13 Nov 2008 04:04:50 -0000 1.8 --- win32notify.cpp 8 Jan 2009 22:11:52 -0000 1.9 *************** *** 240,250 **** Python_OnNotify (CWnd *pFrom, WPARAM, LPARAM lParam, LRESULT *pResult) { - CEnterLeavePython _celp; - PyCCmdTarget *pPyWnd = (PyCCmdTarget *) ui_assoc_CObject::GetPyObject(pFrom); NMHDR *pHdr = (NMHDR *)lParam; - if (pHdr==NULL) return FALSE; // bad data passed? UINT code = pHdr->code; if (pPyWnd==NULL) return FALSE; // no object. --- 240,249 ---- Python_OnNotify (CWnd *pFrom, WPARAM, LPARAM lParam, LRESULT *pResult) { NMHDR *pHdr = (NMHDR *)lParam; if (pHdr==NULL) return FALSE; // bad data passed? UINT code = pHdr->code; + CEnterLeavePython _celp; + PyCCmdTarget *pPyWnd = (PyCCmdTarget *) ui_assoc_CObject::GetAssocObject(pFrom); if (pPyWnd==NULL) return FALSE; // no object. *************** *** 253,258 **** if (!pPyWnd->pNotifyHookList || ! !pPyWnd->pNotifyHookList->Lookup (code, (void *&)method)) return FALSE; // no hook installed. // have method to call. Build arguments. --- 252,260 ---- if (!pPyWnd->pNotifyHookList || ! !pPyWnd->pNotifyHookList->Lookup (code, (void *&)method)) { ! Py_DECREF(pPyWnd); return FALSE; // no hook installed. + } + Py_DECREF(pPyWnd); // have method to call. Build arguments. Index: win32oleDlgInsert.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32oleDlgInsert.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32oleDlgInsert.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- win32oleDlgInsert.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 217,220 **** --- 217,221 ---- RUNTIME_CLASS(COleInsertDialog), sizeof(PyCOleInsertDialog), + PYOBJ_OFFSET(PyCOleInsertDialog), PyCOleInsertDialog_methods, GET_PY_CTOR(PyCOleInsertDialog) ); Index: win32font.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32font.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32font.cpp 3 Jun 2007 12:35:58 -0000 1.4 --- win32font.cpp 8 Jan 2009 22:11:52 -0000 1.5 *************** *** 62,66 **** } } ! return ui_assoc_object::make (PyCFont::type, pFont); } --- 62,69 ---- } } ! PyCFont *ret = (PyCFont *)ui_assoc_object::make (PyCFont::type, pFont, TRUE); ! if (ret) ! ret->bManualDelete = TRUE; ! return ret; } *************** *** 87,90 **** --- 90,94 ---- RUNTIME_CLASS(CFont), sizeof(PyCFont), + PYOBJ_OFFSET(PyCFont), ui_font_methods, GET_PY_CTOR(PyCFont)); Index: win32assoc.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32assoc.h 7 Sep 2004 02:26:20 -0000 1.2 --- win32assoc.h 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 23,35 **** CAssocManager(); ~CAssocManager(); ! void Assoc(void *assoc, ui_assoc_object *PyObject, void *oldAssoc=NULL); ! ui_assoc_object *GetAssocObject(const void * handle); void cleanup(void); // only to be called at the _very_ end private: CMapPtrToPtr map; const void *lastLookup; ! ui_assoc_object *lastObject; ! CCriticalSection m_critsec; #ifdef _DEBUG int cacheLookups; --- 23,37 ---- CAssocManager(); ~CAssocManager(); ! void Assoc(void *assoc, ui_assoc_object *PyObject); ! ui_assoc_object *GetAssocObject(void * handle); void cleanup(void); // only to be called at the _very_ end private: + void RemoveAssoc(void *handle); + // A "map" of weak-references to Python objects. Now we use weakrefs + // this really should be a regular Python dict... CMapPtrToPtr map; const void *lastLookup; ! PyObject *lastObjectWeakRef; #ifdef _DEBUG int cacheLookups; *************** *** 47,51 **** // Given a C++ object, return a PyObject associated (map lookup) ! static ui_assoc_object *GetPyObject(void *search); // Return the C++ object associated with this Python object. --- 49,55 ---- // Given a C++ object, return a PyObject associated (map lookup) ! static ui_assoc_object *GetAssocObject(void *search) { ! return ui_assoc_object::handleMgr.GetAssocObject(search); ! } // Return the C++ object associated with this Python object. *************** *** 55,61 **** static void *GetGoodCppObject(PyObject *&self, ui_type *ui_type_check); - // Call this when the C++ object dies, or otherwise becomes invalid. - void KillAssoc(); // maps to a virtual with some protection wrapping. - // virtuals for Python support virtual CString repr(); --- 59,62 ---- *************** *** 74,83 **** void *GetGoodCppObject(ui_type *ui_type_check=NULL) const; virtual bool CheckCppObject(ui_type *ui_type_check) const {return true;} ! // Does the actual killing. ! virtual void DoKillAssoc( BOOL bDestructing = FALSE ); // does the actual work. ! // Called during KillAssoc - normally zeroes association. ! // Override to keep handle after destruction (eg, the association ! // with a dialog is valid after the Window's window has closed). ! virtual void SetAssocInvalid() { assoc = 0; } ui_assoc_object(); // ctor/dtor --- 75,79 ---- void *GetGoodCppObject(ui_type *ui_type_check=NULL) const; virtual bool CheckCppObject(ui_type *ui_type_check) const {return true;} ! virtual void SetAssocInvalid() { assoc = 0; } // XXX - bogus - called during destruction??? ui_assoc_object(); // ctor/dtor Index: win32control.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32control.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32control.cpp 13 Nov 2008 04:04:50 -0000 1.7 --- win32control.cpp 8 Jan 2009 22:11:52 -0000 1.8 *************** *** 59,62 **** --- 59,63 ---- RUNTIME_CLASS(CObject), sizeof(ui_control_object), + PYOBJ_OFFSET(ui_control_object), ui_control_object_methods, NULL); *************** *** 265,268 **** --- 266,270 ---- RUNTIME_CLASS(CButton), sizeof(PyCButton), + PYOBJ_OFFSET(PyCButton), PyCButton_methods, GET_PY_CTOR(PyCButton)); *************** *** 879,882 **** --- 881,885 ---- RUNTIME_CLASS(CListBox), sizeof(PyCListBox), + PYOBJ_OFFSET(PyCListBox), PyCListBox_methods, GET_PY_CTOR(PyCListBox)); *************** *** 1317,1320 **** --- 1320,1324 ---- RUNTIME_CLASS(CComboBox), sizeof(PyCComboBox), + PYOBJ_OFFSET(PyCComboBox), PyCComboBox_methods, GET_PY_CTOR(PyCComboBox)); *************** *** 1476,1479 **** --- 1480,1484 ---- RUNTIME_CLASS(CProgressCtrl), sizeof(PyCProgressCtrl), + PYOBJ_OFFSET(PyCProgressCtrl), PyCProgressCtrl_methods, GET_PY_CTOR(PyCProgressCtrl)); *************** *** 1991,1994 **** --- 1996,2000 ---- RUNTIME_CLASS(CSliderCtrl), sizeof(PyCSliderCtrl), + PYOBJ_OFFSET(PyCSliderCtrl), PyCSliderCtrl_methods, GET_PY_CTOR(PyCSliderCtrl)); *************** *** 2438,2441 **** --- 2444,2448 ---- RUNTIME_CLASS(CStatusBarCtrl), sizeof(PyCStatusBarCtrl), + PYOBJ_OFFSET(PyCStatusBarCtrl), PyCStatusBarCtrl_methods, GET_PY_CTOR(PyCStatusBarCtrl)); *************** *** 2526,2529 **** --- 2533,2537 ---- RUNTIME_CLASS(CSpinButtonCtrl), sizeof(PyCSpinButtonCtrl), + PYOBJ_OFFSET(PyCSpinButtonCtrl), PyCSpinButtonCtrl_methods, GET_PY_CTOR(PyCSpinButtonCtrl)); Index: win32pen.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32pen.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32pen.cpp 1 Sep 1999 23:33:02 -0000 1.1 --- win32pen.cpp 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 53,56 **** --- 53,57 ---- RUNTIME_CLASS(CPen), sizeof(ui_pen_object), + PYOBJ_OFFSET(ui_pen_object), ui_pen_methods, GET_PY_CTOR(ui_pen_object)); Index: win32ctrlList.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlList.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32ctrlList.cpp 13 Nov 2008 04:04:50 -0000 1.4 --- win32ctrlList.cpp 8 Jan 2009 22:11:52 -0000 1.5 *************** *** 835,838 **** --- 835,839 ---- RUNTIME_CLASS(CListCtrl), sizeof(PyCListCtrl), + PYOBJ_OFFSET(PyCListCtrl), PyCListCtrl_methods, GET_PY_CTOR(PyCListCtrl)); Index: win32gdi.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32gdi.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32gdi.h 1 Sep 1999 23:33:02 -0000 1.1 --- win32gdi.h 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 16,30 **** static CBitmap *GetBitmap (PyObject *self) { return (CBitmap *)GetGdiObject(self, OBJ_BITMAP); } CBitmap *GetBitmap() { return GetBitmap (this); } - BOOL m_deleteObject; protected: PyCGdiObject() - : m_deleteObject(TRUE) { } ~PyCGdiObject(); - virtual void DoKillAssoc( BOOL bDestructing = FALSE ); virtual bool CheckCppObject(ui_type *ui_type_check) const; ! // virtuals for the Python interface. ! virtual CString repr(); }; --- 16,30 ---- static CBitmap *GetBitmap (PyObject *self) { return (CBitmap *)GetGdiObject(self, OBJ_BITMAP); } CBitmap *GetBitmap() { return GetBitmap (this); } protected: PyCGdiObject() { } ~PyCGdiObject(); virtual bool CheckCppObject(ui_type *ui_type_check) const; ! // XXX - PyCGDIObject used to have an 'm_deleteObject' attribute - but all ! // it did was cause a normal 'delete' of the object - ie, identical to the ! // base-class bManualDelete. Its likely the original intent was for the new ! // attribute to determine if ::DeleteObject() should have been called, but ! // that apparently has never happened... }; Index: win32RichEdit.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32RichEdit.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32RichEdit.cpp 13 Nov 2008 04:04:50 -0000 1.3 --- win32RichEdit.cpp 8 Jan 2009 22:11:52 -0000 1.4 *************** *** 83,86 **** --- 83,87 ---- RUNTIME_CLASS(CRichEditDoc), sizeof(PyCRichEditDoc), + PYOBJ_OFFSET(PyCRichEditDoc), PyCRichEditDoc_methods, GET_PY_CTOR(PyCRichEditDoc) ); *************** *** 227,230 **** }; ! PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", &PyCCtrlView::type, &PyCRichEditCtrl::type, RUNTIME_CLASS(CRichEditView), sizeof(PyCRichEditView), PyCRichEditView_methods, GET_PY_CTOR(PyCRichEditView)); --- 228,238 ---- }; ! PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", ! &PyCCtrlView::type, ! &PyCRichEditCtrl::type, ! RUNTIME_CLASS(CRichEditView), ! sizeof(PyCRichEditView), ! PYOBJ_OFFSET(PyCRichEditView), ! PyCRichEditView_methods, ! GET_PY_CTOR(PyCRichEditView)); Index: win32prinfo.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prinfo.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32prinfo.h 28 Oct 1999 01:38:31 -0000 1.2 --- win32prinfo.h 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 5,9 **** ~ui_prinfo_object(); virtual void SetAssocInvalid(); - virtual void DoKillAssoc( BOOL bDestructing = FALSE ); virtual void *GetGoodCppObject(ui_type *ui_type_check=NULL) const; --- 5,8 ---- Index: win32dlgbar.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlgbar.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32dlgbar.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- win32dlgbar.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 85,88 **** --- 85,89 ---- RUNTIME_CLASS(CDialogBar), sizeof(PyCDialogBar), + PYOBJ_OFFSET(PyCDialogBar), PyCDialogBar_methods, GET_PY_CTOR(PyCDialogBar)); Index: win32uioleClientItem.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uioleClientItem.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32uioleClientItem.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- win32uioleClientItem.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 370,373 **** --- 370,374 ---- RUNTIME_CLASS(COleClientItem), sizeof(PyCOleClientItem), + PYOBJ_OFFSET(PyCOleClientItem), PyCOleClientItem_methods, GET_PY_CTOR(PyCOleClientItem) ); Index: win32dll.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dll.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32dll.h 1 Sep 1999 23:33:01 -0000 1.1 --- win32dll.h 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 15,19 **** dll_object(); ~dll_object(); - virtual void DoKillAssoc( BOOL bDestructing = FALSE ); virtual CString repr(); private: --- 15,18 ---- Index: win32cmd.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32cmd.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32cmd.h 1 Sep 1999 23:33:00 -0000 1.1 --- win32cmd.h 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 8,12 **** // class PYW_EXPORT PyCCmdTarget : public ui_assoc_CObject{ ! friend CVirtualHelper::CVirtualHelper(const char *iname, const void *iassoc, EnumVirtualErrorHandling veh); public: // some probably shouldnt be, but... CMapWordToPtr *pNotifyHookList; --- 8,12 ---- // class PYW_EXPORT PyCCmdTarget : public ui_assoc_CObject{ ! friend CVirtualHelper::CVirtualHelper(const char *iname, void *iassoc, EnumVirtualErrorHandling veh); public: // some probably shouldnt be, but... CMapWordToPtr *pNotifyHookList; *************** *** 15,20 **** CMapWordToPtr *pCommandUpdateHookList; - virtual void DoKillAssoc( BOOL bDestructing = FALSE ); - // virtuals for Python support virtual CString repr(); --- 15,18 ---- Index: win32brush.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32brush.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32brush.cpp 3 Jun 2007 12:35:57 -0000 1.2 --- win32brush.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 26,31 **** PyObject *ui_get_halftone_brush(PyObject *self, PyObject *args) { ! PyCBrush *pb = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, CDC::GetHalftoneBrush()); ! pb->m_deleteObject = FALSE; // this is a temp object return pb; } --- 26,31 ---- PyObject *ui_get_halftone_brush(PyObject *self, PyObject *args) { ! PyCBrush *pb = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, CDC::GetHalftoneBrush(), true); ! pb->bManualDelete = FALSE; // this is a temp object return pb; } *************** *** 39,46 **** long cr_color; LOGBRUSH lp; ! // Quick exist to make a empty brush if (PyArg_ParseTuple(args, "")) { // @comm If called with no arguments, an uninitialized brush is created. ! return ui_assoc_object::make (PyCBrush::type, new CBrush); } PyErr_Clear(); --- 39,48 ---- long cr_color; LOGBRUSH lp; ! // Quick exit to make a empty brush if (PyArg_ParseTuple(args, "")) { // @comm If called with no arguments, an uninitialized brush is created. ! PyCBrush *ret = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, new CBrush); ! ret->bManualDelete = TRUE; ! return ret; } PyErr_Clear(); *************** *** 59,63 **** RETURN_ERR ("CreateBrushIndirect call failed"); } ! return ui_assoc_object::make (PyCBrush::type, pBrush); } --- 61,67 ---- RETURN_ERR ("CreateBrushIndirect call failed"); } ! PyCBrush *ret = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, pBrush); ! ret->bManualDelete = TRUE; ! return ret; } *************** *** 95,98 **** --- 99,103 ---- RUNTIME_CLASS(CBrush), sizeof(PyCBrush), + PYOBJ_OFFSET(PyCBrush), PyCBrush_methods, GET_PY_CTOR(PyCBrush)); Index: dllmain.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/dllmain.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dllmain.cpp 13 Nov 2008 04:04:50 -0000 1.6 --- dllmain.cpp 8 Jan 2009 22:11:52 -0000 1.7 *************** *** 212,216 **** // could not have been created. Let the Python code manage if it wants! Win32uiFinalize(); - Python_delete_assoc(pCreatedApp); // so Python wont try and use it. AfxWinTerm(); afxCurrentWinApp = NULL; // So AfxGetApp fails from here. --- 212,215 ---- Index: win32win.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32win.h 13 Nov 2008 04:04:50 -0000 1.4 --- win32win.h 8 Jan 2009 22:11:52 -0000 1.5 *************** *** 17,21 **** PyCWnd(); ~PyCWnd(); - virtual void DoKillAssoc( BOOL bDestructing = FALSE ); public: static CWnd *GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType = &type); --- 17,20 ---- Index: ddetopic.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddetopic.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ddetopic.cpp 10 Nov 2003 04:39:44 -0000 1.1 --- ddetopic.cpp 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 55,58 **** --- 55,59 ---- RUNTIME_CLASS(CDDETopic), sizeof(PyDDETopic), + PYOBJ_OFFSET(PyDDETopic), PyDDETopic_methods, GET_PY_CTOR(PyDDETopic)); *************** *** 73,76 **** --- 74,78 ---- RUNTIME_CLASS(CDDEServerSystemTopic), sizeof(PyDDEServerSystemTopic), + PYOBJ_OFFSET(PyDDEServerSystemTopic), PyDDEServerSystemTopic_methods, GET_PY_CTOR(PyDDEServerSystemTopic)); Index: win32template.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32template.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32template.cpp 13 Nov 2008 04:04:50 -0000 1.5 --- win32template.cpp 8 Jan 2009 22:11:52 -0000 1.6 *************** *** 43,48 **** return; // no more to do. RemoveDocTemplateFromApp(pTemp); - delete pTemp; - SetAssocInvalid(); } --- 43,46 ---- *************** *** 413,416 **** --- 411,415 ---- RUNTIME_CLASS(CDocTemplate), sizeof(PyCDocTemplate), + PYOBJ_OFFSET(PyCDocTemplate), PyCDocTemplate_methods, GET_PY_CTOR(PyCDocTemplate) ); Index: win32dll.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dll.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32dll.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- win32dll.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 22,28 **** dll_object::~dll_object() { ! if (bDidLoadLibrary) ! dll_object::DoKillAssoc(TRUE); // must explicitly call, as virtuals dont work in dtors! } // @pymethod <o PyDLL>|win32ui|LoadLibrary|Creates a DLL object, and loads a Windows DLL into the object. PyObject * --- 22,37 ---- dll_object::~dll_object() { ! if (bDidLoadLibrary = TRUE) { ! ::FreeLibrary (GetDll()); ! TRACE("Python object freeing DLL reference\n"); ! } ! if (pMFCExt) { ! AfxTermExtensionModule(*pMFCExt); // this deletes the DLL. ! delete pMFCExt; ! pMFCExt = NULL; ! pCDLL = NULL; ! } } + // @pymethod <o PyDLL>|win32ui|LoadLibrary|Creates a DLL object, and loads a Windows DLL into the object. PyObject * *************** *** 62,79 **** return ret; } - void dll_object::DoKillAssoc( BOOL bDestructing /*= FALSE*/ ) - { - if (bDidLoadLibrary = TRUE) { - ::FreeLibrary (GetDll()); - TRACE("Python object freeing DLL reference\n"); - ui_assoc_object::DoKillAssoc(bDestructing); - } - if (pMFCExt) { - AfxTermExtensionModule(*pMFCExt); // this deletes the DLL. - delete pMFCExt; - pMFCExt = NULL; - pCDLL = NULL; - } - } // @pymethod |PyDLL|AttachToMFC|Attaches the DLL object to the MFC list of DLL's. // @comm After calling this method, MFC will search this DLL when looking for resources. --- 71,74 ---- *************** *** 151,154 **** --- 146,150 ---- &ui_assoc_object::type, sizeof(dll_object), + PYOBJ_OFFSET(dll_object), dll_methods, GET_PY_CTOR(dll_object)); Index: ddeserver.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddeserver.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ddeserver.cpp 13 Nov 2008 04:04:50 -0000 1.2 --- ddeserver.cpp 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 142,145 **** --- 142,146 ---- RUNTIME_CLASS(CDDEServer), sizeof(PyDDEServer), + PYOBJ_OFFSET(PyDDEServer), PyDDEServer_methods, GET_PY_CTOR(PyDDEServer)); Index: win32prop.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prop.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32prop.h 1 Sep 1999 23:33:02 -0000 1.1 --- win32prop.h 8 Jan 2009 22:11:52 -0000 1.2 *************** *** 16,22 **** PyCPropertySheet(); virtual ~PyCPropertySheet(); - - // virtual void DoKillAssoc( BOOL bDestructing=FALSE); - // virtual void SetAssocInvalid() {return; }//ignore }; --- 16,19 ---- Index: win32dlg.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlg.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32dlg.h 13 Nov 2008 04:04:50 -0000 1.2 --- win32dlg.h 8 Jan 2009 22:11:52 -0000 1.3 *************** *** 21,28 **** PyCDialog(); virtual ~PyCDialog(); - virtual void DoKillAssoc( BOOL bDestructing=FALSE); virtual void SetAssocInvalid() {return; }//ignore public: ! virtual PyObject *getattr(char *name); }; //////////////////////////////////////////////////////// --- 21,27 ---- PyCDialog(); virtual ~PyCDialog(); virtual void SetAssocInvalid() {return; }//ignore public: ! virtual PyObject *getattro(PyObject *obname); }; //////////////////////////////////////////////////////// Index: win32ui.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ui.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32ui.h 6 Dec 2008 00:35:20 -0000 1.9 --- win32ui.h 8 Jan 2009 22:11:52 -0000 1.10 *************** *** 135,153 **** class PYW_EXPORT ui_type : public PyTypeObject { public: ! ui_type( const char *name, ui_type *pBaseType, int typeSize, struct PyMethodDef* methodList, ui_base_class * (* thector)() ); ~ui_type(); public: - ui_type *base; struct PyMethodDef* methods; ui_base_class * (* ctor)(); }; // helper typeCObject class. class PYW_EXPORT ui_type_CObjec... [truncated message content] |
From: Mark H. <mha...@us...> - 2009-01-08 22:08:36
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27011/Pythonwin Modified Files: win32ImageList.cpp Log Message: remove trailing whitespace Index: win32ImageList.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ImageList.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32ImageList.cpp 13 Nov 2008 04:04:50 -0000 1.5 --- win32ImageList.cpp 8 Jan 2009 22:08:20 -0000 1.6 *************** *** 276,280 **** &ui_assoc_CObject::type, RUNTIME_CLASS(CImageList), ! sizeof(PyCImageList), PyCImageList_methods, GET_PY_CTOR(PyCImageList)); --- 276,281 ---- &ui_assoc_CObject::type, RUNTIME_CLASS(CImageList), ! sizeof(PyCImageList), ! PYOBJ_OFFSET(PyCImageList), PyCImageList_methods, GET_PY_CTOR(PyCImageList)); |
From: Mark H. <mha...@us...> - 2009-01-08 22:07:57
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26962/Pythonwin Modified Files: stdafx.h Log Message: remove HIERLIST macro and provide default for WINVER Index: stdafx.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/stdafx.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stdafx.h 14 Mar 2000 23:29:09 -0000 1.2 --- stdafx.h 8 Jan 2009 22:07:52 -0000 1.3 *************** *** 4,10 **** // - //#define HIER_LIST Yay - no more - tree control now used! #define WIN32_LEAN_AND_MEAN #include <afxwin.h> // MFC core and standard components --- 4,15 ---- // #define WIN32_LEAN_AND_MEAN + #ifndef WINVER + // we don't need this, but vs2009 makes noise without it set to something - + // and this is what we currently use... + #define WINVER 0x0600 + #endif + #include <afxwin.h> // MFC core and standard components |