[pywin32-bugs] [ pywin32-Bugs-745304 ] GetObject fails under Win32all-153
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2003-07-12 13:08:13
|
Bugs item #745304, was opened at 2003-05-29 12:53 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=745304&group_id=78018 Category: com Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Andrew Asare (aka_kool) Assigned to: Nobody/Anonymous (nobody) Summary: GetObject fails under Win32all-153 Initial Comment: GetObject fails to retrieve an instance of an object when a moniker is used. For example, when working with WMI the following will fail :- >>> import win32com.client >>> o = win32com.client.GetObject("winmgmts:") Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Python23\lib\site- packages\win32com\client\__init__.py", line 73, in GetObject return Moniker(Pathname, clsctx) File "C:\Python23\lib\site- packages\win32com\client\__init__.py", line 88, in Moniker moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) com_error: (-2147221020, 'Invalid syntax', None, None) I believe there is a bug in the implementation of MkParseDisplayName - possible corruption of passed moniker string. ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2003-07-12 23:08 Message: Logged In: YES user_id=14198 Fixed in 154 and 155. ---------------------------------------------------------------------- Comment By: Ryan Groe (ryangroe) Date: 2003-06-27 11:59 Message: Logged In: YES user_id=773155 In pywin32\com\win32com\src\PythonCOM.cpp, in the function pythoncom_MkParseDisplayName, the variable displayName appears to get set to a narrow string (char *) even though it's declared as a wide string (WCHAR *). When displayName is passed into the function MkParseDisplayName (as the second parameter), its type is correct (a wide character pointer), but the data it contains is wrong. Here's a quick and really dirty fix: 1. add the following somewhere near the top of PythonCOM.cpp: #include <comdef.h> 2. change: hr = MkParseDisplayName(pBC, displayName, &chEaten, &pmk); to: hr = MkParseDisplayName(pBC, (wchar_t *)(_bstr_t) (char *)displayName, &chEaten, &pmk); ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=745304&group_id=78018 |