[python-win32] cannot create 'NoneType' instances
Arun Kumar
arunkakorp at gmail.com
Sun Aug 31 21:27:21 CEST 2008
The problem appeared to have been with another error that I saw only
when I restarted the machine and python. When I first try to import this
module 'import speech' it fails with the error below. Subsequent calls
to 'import speech' fail with the 'NoneType' error.
File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line
554, in AddModuleToCache?
<http://code.google.com/p/pyspeech/w/edit/AddModuleToCache>
dict = mod.CLSIDToClassMap
AttributeError?
<http://code.google.com/p/pyspeech/w/edit/AttributeError>: 'module'
object has no attribute 'CLSIDToClassMap'
This error was being thrown up in the gencache.EnsureModule() call. I
found some posts about deleting the gen_py directory, and retrying the
import and it seems to be working now.
Thanks,
Arun
Larry Bates wrote:
> Arun Kumar wrote:
>> 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
>
> Sounds like oobj is None when you try to call the __init__ method of
> _ListenerBase.
>
> -Larry
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080901/0dc38274/attachment.htm>
More information about the python-win32
mailing list