[pywin32-bugs] [ pywin32-Bugs-3525912 ] InvokeTypes error using win32com v2.17
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2012-05-16 00:32:40
|
Bugs item #3525912, was opened at 2012-05-11 10:37 Message generated for change (Comment added) made by mike_fox You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3525912&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: win32 Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Mike Fox (mike_fox) Assigned to: Nobody/Anonymous (nobody) Summary: InvokeTypes error using win32com v2.17 Initial Comment: I think we have found a bug in win32com 2.17. We are using it with Python 2.7.2. We are calling a proprietary DLL named PATE, which provides APIs to a database named Enovia from the Dassault corporation. The Enovia client is linked to a CAD program named CATIA so we must conjure objects of both CATIA and Enovia as shown in the code snippet below. The strApplicationID is a password administered by my company and has nothing to do with the PATE DLL itself. Rather, PATE should pass the strApplicationID to the Enovia server, which should authenticate the session. ==================================================================== import win32com.client, win32com.client.gencache, win32com.client.selecttlb strPATECLSID = '{9BB3CB79-7098-47D0-83A2-F8F56D236DC8}' strPATEclassCLSID = '{9A1F3C8E-46B7-4CFA-A820-E4256ECD53B5}' self.objCATIA = win32com.client.GetActiveObject('CATIA.Application') win32com.client.gencache.EnsureModule(strPATECLSID, 0, 0, 0) self.objBase= win32com.client.gencache.GetClassForCLSID(strPATEclassCLSID) self.__objPATECOM = self.objBase(self.objCATIA) strApplicationID = <secret> try: self.__objPATECOM.SetApplicationID(strApplicationID) except (pywintypes.com_error), _e: print "Connection error: %s" %(_e) return False ==================================================================== When we use win32com 2.16 the code above works fine but when we use win32com 2.17 it throws the error message shown below. File testKBE_PATECAKE.py, line 367 in ConnectToENOVIA self.__objPATECOM.SetApplicationID(strApplicationID) File "C:\Python27\lib\site-packages\win32com\gen_py\9BB3CB79 -7098-47D0-83A2-F8 F56D236DC8x0x0x0.py", line 457 in SetApplicationID return self._oleobj_.InvokeTypes(1610940417, LCID, 1, (24, 0), ((16396, 1),) , iAID File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516 in __getattr__ raise AttributeError("%s.%s" % (self._username_, attr)) AttributeEror: CATIA.Application.InvokeTypes ---------------------------------------------------------------------- >Comment By: Mike Fox (mike_fox) Date: 2012-05-15 17:32 Message: To Mark Hammond: I don't think the problem is caused by a pre-existing wrapper in the gen_py folder as you suggested in your comment. When I uninstalled version 2.17 of pywin32 and installed version 2.16 on the same PC (with the contents of the gen_py folder unchanged) I was able to call the SetApplicationID method without it throwing an error. ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2012-05-11 19:51 Message: I suspect the problem is that previously you have makepy support generated for the 'CATIA.Application' object which should make things work. The problem is that when you do: self.__objPATECOM = self.objBase(self.objCATIA) The DispatchBaseClass.__init__ function in win32com\client\__init__.py checks to see if the object is itself a makepy generated object and will work correctly if it is. Even though, this really is a bug as we should handle that situation. A fix would probably be to change the line in DispatchBaseClass.__init__ from: elif isinstance(oobj, DispatchBaseClass): to elif hasattr(oobj, "_oleobj_"): ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3525912&group_id=78018 |