[python-win32] Shell extension debugging

Gertjan Klein gklein at xs4all.nl
Tue Jun 30 16:10:06 CEST 2009


Tim Roberts wrote:

>I was going to respond "no" immediately, but now you've got me
>thinking.  Explorer loads the DLL, instantiates the COM object, and
>keeps it loaded forever.  I think that fact alone makes it impossible;
>even if you added a backdoor to reload the module, you still have an
>object in memory using the original implementation.

Ah, but this is what confuses me. I don't have a DLL: I have a .py file,
which gets interpreted by python. The DDLs that get loaded are
python25.dll and two pywin32 dlls (don't remember offhand which). So,
when the extension is first loaded, pywin32 must load python, compile
the extension, and execute its methods. If it were possible to replace
the compiled python code with a newer version this should work,
shouldn't it? Because the dlls that Windows sees are still there.

I haven't even though about using something like py2exe to compile the
entire app into something distibutable yet, but it seems safe to assume
that in that situation, replacing the code wouldn't work (but I don't
mind that).

>Oh, don't be afraid of the logging module.

I'm not -- I have used in the past. I just don't like it. In this
situation, it may be waht I end up using, I haven't decided yet;
replacing stdout and stderr with something basic should work too.

>I would be very surprised.  You need to be able to attach to an existing
>process, and I don't know of any Python debuggers that can do that.

I have downloaded (but not yet used or studied) WinPdb. It has a menu
entry File->Attach, which claims to be able to "attach to a script (that
has the debugger engine running)". Perhaps this can be used; I'll
experiment.

Regards,
Gertjan.




More information about the python-win32 mailing list