On Fri, 2012-04-20 at 15:52 +1000, Mark Hammond wrote: > On 20/04/2012 8:30 AM, Lloyd Kvam wrote: > > On Thu, 2012-04-19 at 16:32 -0400, Lloyd Kvam wrote: > >> I am hoping one of you can point me in the right direction. My > >> alternative appears to be (painfully) writing some VB code to discard > >> the traceback lines from Err.Description. > > Hrm - I thought it had always been the case that if you throw an > explicit COMException, then you shouldn't get the traceback - the > traceback only appears for "other" exceptions, which presumably indicate > the exception was unintended. >
The COMException is the code I added. Up until now I had not translated the Python exceptions into COMExceptions. This had worked OK. > > > > I read more carefully through Python Programming on Win32 and came up > > with this code: > > > > """""""""""""""""""""""""""""""""""""""""""""""""""""""""" > > class DefaultDebugDispatcher( > > win32com.server.dispatcher.DefaultDebugDispatcher): > > def _HandleException_(self): > > excls,exself = sys.exc_info()[:2] > > if not IsCOMServerException(excls): > > raise COMException(description = str(exself), > > scode = winerror.E_INVALIDARG, > > ) > > Which seems to backup my point - IsCOMServerException() is returning > false, so the exception isn't a COMException, so you turn it into one > and avoid the traceback etc. > > Note however that you could just also raise a COMException directly from > the original point - ie, there should be no need to convert to a > COMException if a COMException is thrown in the first place. The original code is meant to run on any supported OS. It's just normal Python. I do my development work using Linux. The COM object is created by simply using a module to wrap the application into a COM object using the pywin32 services. Up until now, the Python exceptions with their error messages simply percolated up to the VB GUI. > How are you throwing the original? If you thought you were throwing a > COMException then we would want to check you actually are if you still > think so, dig into why IsCOMServerException is failing. > > Cheers, > > Mark Thank you very, very much for your efforts integrating Python and Windows. The core application is around 14,000 lines of code. The wrapper module to turn it into a COM object for deployment in Windows is just under 600 lines. -- Lloyd Kvam Venix Corp DLSLUG/GNHLUG library http://dlslug.org/library.html http://www.librarything.com/catalog/dlslug http://www.librarything.com/catalog/dlslug&sort=stamp http://www.librarything.com/rss/recent/dlslug _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32