Discussion:
[python-win32] Unexpected exception in gateway method 'AddTypeLib' with own Active Script Host
Johan Lindvall
2006-08-25 10:12:00 UTC
Permalink
Hi,

We are sometimes getting the error below when running a Python script in our
app.

We are calling AddTypeLib on the IActiveScript interface.

It always works with VB-scripts and sometimes fails with Python.

What could be the problem?

===============================================
pythoncom error: Unexpected exception in gateway method 'AddTypeLib'
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in
*InvokeEx*
return self.*invokeex*(dispid, lcid, wFlags, args, kwargs, serviceProvider)
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in
*invokeex*
return func(*args)
File
"C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py",
line 688, in AddTypeLib
gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520,
in EnsureModule
module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor,
progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290,
in MakeModuleForTypelib
return GetModuleForTypelib(typelibCLSID, lcid, major, minor)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258,
in GetModuleForTypelib
mod = _GetModule(modName)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629,
in _GetModule
mod = _*import*_(mod_name)
exceptions.ImportError: No module named
E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4
pythoncom error: Unexpected gateway error
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in
*InvokeEx*
return self.*invokeex*(dispid, lcid, wFlags, args, kwargs, serviceProvider)
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in
*invokeex*
return func(*args)
File
"C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py",
line 688, in AddTypeLib
gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520,
in EnsureModule
module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor,
progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290,
in MakeModuleForTypelib
return GetModuleForTypelib(typelibCLSID, lcid, major, minor)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258,
in GetModuleForTypelib
mod = _GetModule(modName)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629,
in _GetModule
mod = _*import*_(mod_name)
exceptions.ImportError: No module named
E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4
=====================================================

Thanks
--
/Johan.
Mark Hammond
2006-08-26 07:10:07 UTC
Permalink
Could you try executing win32com\client\makepy.py as a script (eg, from a
cmd-prompt), then select the typelib from the list that will be displayed,
and see if it works there? According to the traceback, win32com believes it
successfully generated the file, but then failed to locate it.

Mark.
-----Original Message-----
From: python-win32-***@python.org
[mailto:python-win32-***@python.org]On Behalf Of Johan Lindvall
Sent: Friday, 25 August 2006 8:12 PM
To: Python-***@python.org
Subject: [python-win32] Unexpected exception in gateway method
'AddTypeLib'with own Active Script Host


Hi,

We are sometimes getting the error below when running a Python script in
our app.

We are calling AddTypeLib on the IActiveScript interface.

It always works with VB-scripts and sometimes fails with Python.

What could be the problem?

===============================================
pythoncom error: Unexpected exception in gateway method 'AddTypeLib'
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332,
in
InvokeEx
return self.invokeex(dispid, lcid, wFlags, args, kwargs, serviceProvider)
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588,
in
invokeex
return func(*args)
File
"C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py",
line 688, in AddTypeLib
gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
520,
in EnsureModule
module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor,
progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
290,
in MakeModuleForTypelib
return GetModuleForTypelib(typelibCLSID, lcid, major, minor)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
258,
in GetModuleForTypelib
mod = _GetModule(modName)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
629,
in _GetModule
mod = _import_(mod_name)
exceptions.ImportError: No module named
E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4
pythoncom error: Unexpected gateway error
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332,
in
InvokeEx
return self.invokeex(dispid, lcid, wFlags, args, kwargs, serviceProvider)
File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588,
in
invokeex
return func(*args)
File
"C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py",
line 688, in AddTypeLib
gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
520,
in EnsureModule
module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor,
progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
290,
in MakeModuleForTypelib
return GetModuleForTypelib(typelibCLSID, lcid, major, minor)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
258,
in GetModuleForTypelib
mod = _GetModule(modName)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
629,
in _GetModule
mod = _import_(mod_name)
exceptions.ImportError: No module named
E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4
=====================================================

Thanks

--
/Johan.
Johan Lindvall
2006-08-28 06:22:28 UTC
Permalink
Could you try executing win32com\client\makepy.py as a script (eg, from a cmd-prompt), then select the typelib from the list that will be displayed, and see if it works there? According to the traceback, win32com believes it successfully generated the file, but then failed to locate it.
Makepy.py works and generates code for the complete typelib (including
all methods). The generated python file is placed in win32com\gen_py.
By method code I mean code like this:

def Exit(self):
"""Exits the application"""
return self._oleobj_.InvokeTypes(58, LCID, 1, (24, 0), (),)

With AddTypeLib, the partial code for the typelib is placed in a
subdirectory of win32com\gen_py.With partial I mean that there is no
code generated for the methods.

If i delete the generated files and call AddTypeLib, it always fails.
If I call it when there is generated typelib data available, it works.

Thanks
--
/Johan.
Johan Lindvall
2006-08-28 12:18:30 UTC
Permalink
The error was in our code.

IActiveScriptSite::GetLCID returned garbage (even though we used the
sample provided by Microsoft).

Regards,
--
/Johan.
Loading...