[python-win32] Automation server returns BSTR, but Python client gets unicode error.

apocalypznow apocalypznow at yahoo.com
Sun Sep 5 12:11:08 CEST 2004


Hi,

I implemented an automation server, and a python client that calls it. 
One of the automation server methods returns a VARIANT, which the python 
  client is supposed to interpret as a string.  I get a unicode error 
from  the call to the automation server method as follows:
s = automationserver.SendMessage("Hello Automationserver")
TypeError: 'unicode' object not callable

The automation server method in question is as follows:

VARIANT CTestmfcautomationserverDlgAutoProxy::SendMessage(const VARIANT 
FAR& param1)
{
	VARIANT vaResult;
	VariantInit(&vaResult);
	AfxMessageBox(_T("SendMessage is hit!"));
	vaResult.vt = VT_BSTR;
	CComBSTR bstr("<Got it!>");
	BSTR txt = bstr.Detach();
	vaResult.bstrVal = txt;
	return vaResult;
}

The relevant part of the odl (idl) file definition is as follows:
dispinterface ITestmfcautomationserver
{
	properties:
	methods:
		[id(1)] VARIANT SendMessage(VARIANT param1);
};

How do I fix this?



More information about the Python-win32 mailing list