Bug in COM Makepy utility? (ActivePython 2.4)

S

Steve M

When I use the COM Makepy utility on one computer with WindowsXP,
ActivePython 2.3 and I select the library Microsoft Word 10.0 Object
Library (8.2), things work fine.
When I have WindowsXP, ActivePython 2.4 (build 247) and Microsoft Word
11.0 Object Library (8.3), then I get the following SyntaxError, and on
two different computers I tested this. More on the error below, but has
anyone else had this problem? Will there soon be a newer build of
ActivePython? I've never used the standard Python distribution with
manually installed win32all package, just because its so easy to deploy
ActivePython. Should I consider switching, now that I'm on the topic?

Building definitions from type library...
Generating...
Importing module
Failed to execute command:
from win32com.client import makepy;makepy.main()
Traceback (most recent call last):
File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\toolmenu.py",
line 103, in HandleToolCommand
exec "%s\n" % pyCmd
File "<string>", line 1, in ?
File "C:\Python24\lib\site-packages\win32com\client\makepy.py", line
363, in main
GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel,
bForDemand = bForDemand, bBuildHidden = hiddenSpec)
File "C:\Python24\lib\site-packages\win32com\client\makepy.py", line
274, in GenerateFromTypeLibSpec
gencache.AddModuleToCache(info.clsid, info.lcid, info.major,
info.minor)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py",
line 555, in AddModuleToCache
mod = _GetModule(fname)
File "C:\Python24\Lib\site-packages\win32com\client\gencache.py",
line 634, in _GetModule
mod = __import__(mod_name)
File
"C:\Python24\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-000000000046x0x8x3\__init__.py",
line 2831
'{00020960-0000-0000-C000-000000000046}' : 'Pane',
'{00020961-0000-0000-C000-000000000046}' : 'Windows',
^
SyntaxError: invalid syntax


I don't entirely understand the error (I'm rather ignorant of the whole
process Makepy is doing, come to think of it...). First of all, when I
load the file with the alleged syntax error into Scite, the line where
the caret is pointing to is actually 2838, not line 2831. Further, I
cannot detect any syntax errors based on visual inspection. In fact,
when I copy/paste lines 2830-2840 into a new script and put "d = {"
before the lines and "}" after the lines, it is syntactically valid
python that executes without complaint. I don't know how "dynamically"
this file is being generated, but somethin' ain't right.
 
S

Steve M

After exploring the bug database I discovered that this bug has been
reported since March, and appears to derive from a bug in Python
itself.

http://bugs.activestate.com/show_bug.cgi?id=38052

It apparently only happens when the code generated by Makepy is really
big (which it is for Word or Excel).

So my options are to downgrade from Python 2.4.1 to 2.3.5 or to use
Late Binding instead of Early Binding (as described in Hammond and
Robinson, Ch. 12). The easiest path will be to use Early Binding,
because as far as I can tell the only significant changes to code will
be that I have to use integer literals instead of named constants. In
my case this means replacing
'win32com.client.constants.wdSendToNewDocument' with '0' (zero).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top