[python-win32] win32all 152 + COM server + py2exe == trouble

Mark Hammond mhammond@skippinet.com.au
Mon, 10 Mar 2003 10:52:03 +1100


> Point well taken about win32traceutil.  I assumed it didn't work at all in
> py2exe because I had some trouble using it that way, but importing it
> explicitly worked, and gave me the following tb:

...

>   File "win32com\server\register.pyc", line 188, in RegisterServer
> AttributeError: 'module' object has no attribute 'frozen'

Having a look at this shows:

  if pythoncom.frozen:
    assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set -
don't know the context!"
    if sys.frozen == "dll":

In McMillan's installer, if pythoncom.frozen is set, sys.frozen will be
either 1 (for backwards compat, meaning .exe) or "dll", meaning a DLL.
register.py is trying to work out how to register itself, as these 2 cases
are different.  (Previously, McMillan, and I presume py2exe, had nasty hacks
to perform correct registration of COM objects.  It made much more sense to
me for win32com to directly support these advanced registation requirements.
Thus, there may be py2exe hacks that could be removed)

If someone can suggest a change here, that would be great.  For now, simply
remove the assert, and change the following line to:

    if hasattr(sys, "frozen") and sys.frozen == "dll":

This will force register.py to take the 'else' path here, assuming a .exe.
Let me know if that is all that is broken.

Mark.