[python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"?

Terry Davis terry.y.davis at gmail.com
Mon Jan 27 18:33:15 EST 2020


Hi all,

I tried searching the mailing list archives for "com_record" but didn't
find anything relevant.

For context, I'm trying to access a COM interface defined in a .tlb file.

Here's a skeleton of the script I'm using to expose this interface:
import pythoncom
from win32com.client import gencache

lib_GUID = "{<GUID>}"
lib_major = 1
lib_minor = 0
lib_pyITypelib = pythoncom.LoadRegTypeLib(lib_GUID, lib_major, lib_minor)
lib = gencache.EnsureModuleForTypelibInterface(_lib_pyITypelib)

ccs = lib.CControlServer()  # CControlServer is a CoClass
eid, *other = ccs.LoadExperiment(**path to file**)  # Works
ccs.GetSoftwareInfo()  # Fails with exception below.
ccs.GetSolvent(eid)  # also fails

I can't dig down in the debugger to find the source of the exception, so
I'm hoping someone here can help!


Exception:

def GetSoftwareInfo(self, info=pythoncom.Missing):


<ipython-input-8-7304ad54d54a> in <module>
----> 1 ccs.GetSoftwareInfo()

~\AppData\Local\Temp\gen_py\3.7\<GUID>x0x1x0.py in GetSoftwareInfo(self,
info)
    279         def GetSoftwareInfo(self, info=pythoncom.Missing):
    280                 'method GetSoftwareInfo'
--> 281                 return self._ApplyTypes_(13, 1, (24, 0), ((36,
2),), 'GetSoftwareInfo', None,info
    282                         )
    283

C:\Python37\lib\site-packages\win32com\client\__init__.py in
_ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID,
*args)
    465         def _ApplyTypes_(self, dispid, wFlags, retType, argTypes,
user, resultCLSID, *args):
    466                 return self._get_good_object_(
--> 467                         self._oleobj_.InvokeTypes(dispid, 0,
wFlags, retType, argTypes, *args),
    468                         user, resultCLSID)
    469

TypeError: Only com_record objects can be used as records
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20200127/b6782f2e/attachment-0001.html>


More information about the python-win32 mailing list