[python-win32] f(win32all, COM server, py2exe) continued

Cory Dodt corydodt@yahoo.com
Fri, 14 Mar 2003 15:42:57 -0800 (PST)


Ok, tried with your patch--pasted at the end--and registration is no
longer a problem.  win32traceutil gives me "Registered blah blah (for
debugging)" as it should, registry key is fine (although different...)
etc.

Now the problem is when I run the sucker, my process (App.exe) hangs,
hangs, hangs, hangs, dies.  This happens as soon as I do a Dispatch from
python, or for example a CreateObject in VBA.  And it blocks.  Fun!

This is the error I get from the client side:

'''pywintypes.com_error : (-2146959355, 'Server execution failed', None,
None)'''

I have no server-side debugging information to offer at this point. 
win32traceutil sits there quietly while this happens.

The only thing I noticed is that the command line has changed.  In the
registry I used to have: 

HKEY_CLASSES_ROOT\CLSID\{B5772D53-62F1-4B23-902E-7DA4B9DD4902}\LocalServer32

== C:\PROGRA~1\Lexicon\App.exe {B5772D53-62F1-4B23-902E-7DA4B9DD4902}

Now I have:

== C:\PROGRA~1\Lexicon\App.exe /Automate



--- Mark Hammond <mhammond@skippinet.com.au> wrote:
> > 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.
> 
--- register.py.orig    2003-03-14 15:11:10.000000000 -0800
+++ register.py 2003-03-14 15:11:24.000000000 -0800
@@ -185,8 +185,8 @@
   # And if we are frozen, ignore the ones that don't make sense in this
   # context.
   if pythoncom.frozen:
-    assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set -
don't know the context!"
-    if sys.frozen == "dll":
+#    assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set -
don't know the context!"
+    if hasattr(sys, "frozen") and sys.frozen == "dll":
       clsctx = clsctx & pythoncom.CLSCTX_INPROC_SERVER
     else:
       clsctx = clsctx & pythoncom.CLSCTX_LOCAL_SERVER


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com