[python-win32] 'NoneType' object is not callable
Mark Hammond
mhammond at skippinet.com.au
Tue Sep 7 05:10:32 CEST 2004
> I always get this error when calling a function on the automation
> server: 'NoneType' object is not callable
> Then the python program stops executing. In the code below,
> mfcserver.SendMessage1() gives the error, and the print
> "Finished" line
> never executes.
Your COM server is reponding to a request for a *property* named
"SendMessage1", and returning None. Python it then attempting to call it.
You should raise DIS_E_MEMBERNOTFOUND when it is requested as a property.
You can worm around that using:
ob._FlagAsMethod("SendMessage1") before trying to make the call.
> It looks as though the dispatch is happening dynamically. The error
> happens even if gencache is not used.
That means your object is not responding to GetTypeInfo() - so python has no
clue what type lib info to use. You should be able to worm around that by:
mod = gencache.EnsureModule('{6CAC46EE-C71C-475C-B372-2E988DA78678x0x1x0}',
0, 1, 0)
mfcserver = win32com.client.Dispatch("Testmfcserver.Application")
mfcserver = mod.Application(mfcserver)
mfcserver.SendMessage1("Hello server.")
ie, if that works, there should be no need to use _FlagAsMethod (indeed, it
will fail)
Mark
More information about the Python-win32
mailing list