[python-win32] Trouble running profiler

Christopher Brichford chrisb at adobe.com
Mon Apr 4 19:29:21 CEST 2005


	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.
-------------- next part --------------
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 "python\profileTest.py", line 22, in ?
    msXMLDOM.load( xmlFileName )
  File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 455, in __getattr__
    if self.__LazyMap__(attr):
  File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 355, in __LazyMap__
    debug_attr_print("%s.__LazyMap__(%s) added something" % (self._username_,attr))
  File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 61, in debug_attr_print
    def debug_attr_print(*args):
  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, 'Bind'))
-------------- next part --------------
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' )
	assert msXMLDOM is not None
	msXMLDOM.load( xmlFileName )


More information about the Python-win32 mailing list