[pywin32-checkins] pywin32/com/win32com/client dynamic.py, 1.24, 1.25
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-11-26 02:17:17
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15233/com/win32com/client Modified Files: dynamic.py Log Message: minor tweaks for working with py3k Index: dynamic.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** dynamic.py 11 Nov 2008 00:56:06 -0000 1.24 --- dynamic.py 26 Nov 2008 01:38:42 -0000 1.25 *************** *** 16,19 **** --- 16,20 ---- """ + import sys import traceback import types *************** *** 63,66 **** --- 64,74 ---- print + # A helper to create method objects on the fly + if sys.version_info > (3,0): + def MakeMethod(func, inst, cls): + return types.MethodType(func, inst) # class not needed in py3k + else: + MakeMethod = types.MethodType # all args used in py2k. + # get the type objects for IDispatch and IUnknown dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] *************** *** 172,176 **** def __nonzero__(self): ! return 1 # ie "if object:" should always be "true" - without this, __len__ is tried. # _Possibly_ want to defer to __len__ if available, but Im not sure this is # desirable??? --- 180,184 ---- def __nonzero__(self): ! return True # ie "if object:" should always be "true" - without this, __len__ is tried. # _Possibly_ want to defer to __len__ if available, but Im not sure this is # desirable??? *************** *** 306,310 **** # Save the function in map. fn = self._builtMethods_[name] = tempNameSpace[name] ! newMeth = types.MethodType(fn, self, self.__class__) return newMeth except: --- 314,318 ---- # Save the function in map. fn = self._builtMethods_[name] = tempNameSpace[name] ! newMeth = MakeMethod(fn, self, self.__class__) return newMeth except: *************** *** 440,444 **** # If a known method, create new instance and return. try: ! return types.MethodType(self._builtMethods_[attr], self, self.__class__) except KeyError: pass --- 448,452 ---- # If a known method, create new instance and return. try: ! return MakeMethod(self._builtMethods_[attr], self, self.__class__) except KeyError: pass |