[pywin32-bugs] [ pywin32-Bugs-740417 ] Potential error concealment in COM server initialization
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2003-06-01 12:53:21
|
Bugs item #740417, was opened at 2003-05-20 22:31 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=740417&group_id=78018 Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Max Shiyanovsky (shiyanovsky) Assigned to: Nobody/Anonymous (nobody) Summary: Potential error concealment in COM server initialization Initial Comment: file win32com\server\policy.py class BasicWrapPolicy: def _CreateInstance_(self, clsid, reqIID) this function brings some danger in case of win32api.error raise from server initialization routine. I'd suggest to move except statement some rows above to except only CLSID/PythonCom key reading failure. ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2003-06-01 22:53 Message: Logged In: YES user_id=14198 Sorry - I was looking at the global _CreateInstance function. A patch speaks a thousand words <wink> Checking in policy.py; policy.py new revision: 1.14; previous revision: 1.13 ---------------------------------------------------------------------- Comment By: Max Shiyanovsky (shiyanovsky) Date: 2003-05-31 02:01 Message: Logged In: YES user_id=782829 the whole code of _CreateInstance_ lookis like (doc-string omitted) def _CreateInstance_(self, clsid, reqIID): try: classSpec = win32api.RegQueryValue (win32con.HKEY_CLASSES_ROOT, regSpec % clsid) myob = call_func(classSpec) self._wrap_(myob) return pythoncom.WrapObject(self, reqIID) except win32api.error: raise error, "The object is not correctly registered - %s key can not be read" % (regSpec % clsid) The call myob = call_func(classSpec) may raise an exception and furthermore exactly win32api.error. Certainly it's my bug that don't handle such an exception in class ctor (in my case callable object is a class). But as a result I've got a wrong message "object is not correctly registered". I suggest to wrap in try-except only win32api.RegQueryValue call. ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2003-05-27 12:01 Message: Logged In: YES user_id=14198 I don't quite follow this. Object creation should be in the code: if dispatcher: retObj = dispatcher(policy, None) else: retObj = policy(None) return retObj._CreateInstance_(clsid, reqIID) And this is not wrapped in an except handler. I guess that getting the dispatcher class could fail, but that seems alot less likely than the class constructor failing. Can you please give me a real example of what could fail? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=740417&group_id=78018 |