[python-win32] cannot create 'NoneType' instances

Arun Kumar arunkakorp at gmail.com
Sun Aug 31 20:27:54 CEST 2008


hi,
I'm new to python as well as pywin. I'm having trouble with the 
following code:

_ListenerBase = win32com.client.getevents("SAPI.SpSharedRecoContext")
class _ListenerCallback(_ListenerBase):

    """Created to fire events upon speech recognition.  Instances of this
    class automatically die when their listener loses a reference to
    its grammar.  TODO: we may need to call self.close() to release the
    COM object, and we should probably make goaway() a method of self
    instead of letting people do it for us.
    """

    def __init__(self, oobj, listener, callback):
        _ListenerBase.__init__(self, oobj)
        self._listener = listener
        self._callback = callback

    def OnRecognition(self, _1, _2, _3, Result):
        # When our listener stops listening, it's supposed to kill this
        # object.  But COM can be funky, and we may have to call close()
        # before the object will die.
        if self._listener and not self._listener.islistening():
            self.close()
            self._listener = None

        if self._callback and self._listener:
            newResult = win32com.client.Dispatch(Result)
            phrase = newResult.PhraseInfo.GetText()
            self._callback(phrase, self._listener)

The error I get is:
class _ListenerCallback(_ListenerBase):
TypeError: Error when calling the metaclass bases
    cannot create 'NoneType' instances

I went through the list archives and found a couple of messages 
regarding this, so I tried the following in an interactive shell:
 >>> lb = win32com.client.getevents("SAPI.SpSharedRecoContext")
 >>> type(lb)
<type 'NoneType'>

Can anyone point me in the right direction? Why is getevents returning a 
NoneType? How can I fix it?

Thanks,
Arun


More information about the python-win32 mailing list