[python-win32] win32com- Type mismatch on a string... Possible hash key collision?

Reedick, Andrew jr9445 at ATT.COM
Wed Jan 2 21:10:28 CET 2008


I'm converting working Perl COM scripts to Python (ActivePython
2.5.1.1)and I've hit an odd situation where win32com throws a 'Type
mismatch' error on a string.

It's odd because a) it works in ActiveState Perl, b) other methods in
the object work just fine in Python, and c) it looks suspiciously like a
key collision in an internal hash.

The following method works successfully:
	a = self.tdc.Customization.Fields.Field("REQ", "RQ_REQ_ID")
	print a.ColumnName

but the following fails:
	b = self.tdc.Customization.Fields.Fields("BUG")

I think the problem is "...Fields.Fields(...)"  The two Fields objects
are different objects but happen to have the same name.  (The 1st Fields
is a CustomizationFields object, and the 2nd Fields is TDField object
with different properties and different methods.)


I have extra debugging turned on in
Python25\lib\site-packages\win32com\client\dynamic.py.  Here's the
debugging with notes and the traceback:

	TDApiOle80.TDConnection.__LazyMap__(InitConnectionEx) added
something
	TDApiOle80.TDConnection.__LazyMap__(Login) added something
	TDApiOle80.TDConnection.__LazyMap__(Connect) added something
	TDApiOle80.TDConnection.__LazyMap__(ProjectConnected) added
something

	Attribute ProjectConnected not in cache
	Getting property Id 0x2 from OLE object
	OLE returned  True
	TDApiOle80.TDConnection.__LazyMap__(Customization) added
something

	Attribute Customization not in cache
	Getting property Id 0x1a from OLE object
	OLE returned  <PyIDispatch at 0xb409b4 with obj at 0xdbfebc>
	<unknown>.__LazyMap__(Fields) added something

a = self.tdc.Customization.Fields.Field("REQ", "RQ_REQ_ID")

self.tdc.Customization.Fields.Field
	Attribute Fields not in cache
	Getting property Id 0x6 from OLE object
	OLE returned  <PyIDispatch at 0xa4692c with obj at 0xdb39a4>
	<unknown>.__LazyMap__(Field) added something

print a.ColumnName
	Field.__LazyMap__(ColumnName) added something
	Attribute ColumnName not in cache
	Getting property Id 0x13 from OLE object
	OLE returned  RQ_REQ_ID
	RQ_REQ_ID


b = self.tdc.Customization.Fields.Fields("BUG")

	Attribute Customization not in cache
	Getting property Id 0x1a from OLE object
	OLE returned  <PyIDispatch at 0xabaa34 with obj at 0xdbfebc>
	<unknown>.__LazyMap__(Fields) added something

self.tdc.Customization.Fields
	Attribute Fields not in cache
	Getting property Id 0x6 from OLE object
	OLE returned  <PyIDispatch at 0xac0a54 with obj at 0xdb39a4>
	<unknown>.__LazyMap__(Fields) added something

self.tdc.Customization.Fields.Fields
	Attribute Fields not in cache
	Getting property Id 0x2 from OLE object
	OLE returned  <PyIDispatch at 0xae22b4 with obj at 0x18b7270>

boom	Traceback (most recent call last):
	  File "TDC.py", line 112, in <module>
	    tdc.MapUserFields2DatabaseFields('BUG')
	  File "TDC.py", line 61, in MapUserFields2DatabaseFields
	    b = self.tdc.Customization.Fields.Fields("BUG")
	  File
"c:\Python25\lib\site-packages\win32com\client\dynamic.py", line 172, in
	__call__
	    return
self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.
	defaultDispatchName,None)
	pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)


How the heck do you get a Type Mismatch on a string?

Again, the ...Fields.Field("TableName", "FieldName") method works just
fine, but ...Fields.Fields("TableName") method fails miserably.  



*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA623




More information about the python-win32 mailing list