I get a similar errors if I use win32com.client.gencache.EnsureDispatch instead of win32com.client.Dispatch. You get different error depending on the contents of the pythonroot\lib\site-packages\win32com\gen_py\ directory. If pythonroot\lib\site-packages\win32com\gen_py\ is empty then you get the stack trace in the attachment error1.txt. After you run the test program once with or without the profiler, the pythonroot\lib\site-packages\win32com\gen_py\ will not be empty. When you run the test program the second time you get the stack trace in the attachment error2.txt
I was purposely using the dynamic version because the gencache stuff does not work if you run python as a restricted user. This seems to be due to the fact that a restricted user can not make directories in pythonroot\lib\site-packages\win32com\gen_py\... If I were to use the non-dynamic code I would need a way to specify that all generated files should be put somewhere under the user's profile. I stopped using the Microsoft XML parser so I don't really need to use win32com anymore. I switch to the sgmlop parser which works fine with the profiler. If you are interested in continuing to work on this issue, I'm more than happy to keep trying your suggestions. Chris Brichford Mark Hammond wrote: > I'm afraid I haven't recently used the profiler with win32com. I have > recently used hotshot (which works quite well), but not with > "win32com.client.dynamic" objects. I've no idea where that error is coming > from. > > I'm not sure of the real issue, but I do note that the problem occurs when > building "dynamic" information for the object. Try running makepy first - > this could be as simple as using win32com.client.gencache.EnsureDispatch() > instead of a simple Dispatch. That should avoid the failing code (and > hopefully not just find something else that fails). > > Mark. > > >>-----Original Message----- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] Behalf Of Christopher >>Brichford >>Sent: Tuesday, 5 April 2005 3:29 AM >>To: python-win32@python.org >>Subject: [python-win32] Trouble running profiler >> >> >> I'm try to run the profiler on a program that uses >>win32com.client to >>access the Msxml2.DOMDocument COM class to load an XML document. I >>have attaced the stack trace I get when I run: >> >>python.exe -m profile profileTest.py >> >>I have also attached profileTest.py. The profiler seems to work fine >>on programs that don't use win32com.client. Has anyone seen this >>problem before? >> >>For those of you who are curious as to why I'm using the microsoft xml >>parser: >>The xml files I'm reading were created by a microsoft product and >>contain newline characters in attribute values. xml.dom.minidom >>converts the newlines in the attribute values to reqular spaces. It >>is important that these new line characters are preserved. I >>discovered that the microsoft xml parser preserves new line characters >>in an element's attribute value so I started using the win32com.client >>stuff to get at microsoft's xml parser. >> >> >>Thanks in advance, >>Christopher Brichford >>Acrobat Engineering >>Adobe Systems Inc. >> > >
import optparse import win32com.client if __name__ == u'__main__': usageStr = ( u'usage: %prog [options] xmlFileName ' ) optParser = optparse.OptionParser( usage=usageStr ) ( options, args ) = optParser.parse_args() errorStr = u'' if ( len( args ) < 1 ): errorStr = errorStr + u'Missing xml file name argument.' if ( len( errorStr ) > 0 ): raise Exception( errorStr ) assert len( args ) > 0 xmlFileName = args[ 0 ] #msXMLDOM = win32com.client.Dispatch( u'Msxml2.DOMDocument' ) msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) assert msXMLDOM is not None msXMLDOM.load( xmlFileName )
Traceback (most recent call last): File "c:\Program Files\Python\2.4\lib\profile.py", line 611, in ? run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) File "c:\Program Files\Python\2.4\lib\profile.py", line 72, in run prof = prof.run(statement) File "c:\Program Files\Python\2.4\lib\profile.py", line 448, in run return self.runctx(cmd, dict, dict) File "c:\Program Files\Python\2.4\lib\profile.py", line 454, in runctx exec cmd in globals, locals File "<string>", line 1, in ? File "profileTest.py", line 21, in ? msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 536, in EnsureDispatch mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 245, in GetModuleForTypelib def GetModuleForTypelib(typelibCLSID, lcid, major, minor): File "c:\Program Files\Python\2.4\lib\profile.py", line 238, in trace_dispatch_i if self.dispatch[event](self, frame, t): File "c:\Program Files\Python\2.4\lib\profile.py", line 295, in trace_dispatch_call assert (self.cur is None or \ AssertionError: ('Bad call', ('', 0, 'unlink'))
Traceback (most recent call last): File "c:\Program Files\Python\2.4\lib\profile.py", line 611, in ? run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) File "c:\Program Files\Python\2.4\lib\profile.py", line 72, in run prof = prof.run(statement) File "c:\Program Files\Python\2.4\lib\profile.py", line 448, in run return self.runctx(cmd, dict, dict) File "c:\Program Files\Python\2.4\lib\profile.py", line 454, in runctx exec cmd in globals, locals File "<string>", line 1, in ? File "profileTest.py", line 21, in ? msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 537, in EnsureDispatch GetModuleForCLSID(disp_clsid) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 204, in GetModuleForCLSID def GetModuleForCLSID(clsid): File "c:\Program Files\Python\2.4\lib\profile.py", line 238, in trace_dispatch_i if self.dispatch[event](self, frame, t): File "c:\Program Files\Python\2.4\lib\profile.py", line 295, in trace_dispatch_call assert (self.cur is None or \ AssertionError: ('Bad call', ('c:\\Program Files\\Python\\2.4\\lib\\site-packages\\win32com\\client\\gencache.py', 368, 'EnsureModule'))
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32