[python-win32] Shell extension debugging

Tim Golden mail at timgolden.me.uk
Tue Jun 30 14:57:30 CEST 2009


Tim Golden wrote:
> Thomas Heller wrote:
>> Gertjan Klein schrieb:
>>>>> 2) I see print statements in the source code, but I have no idea where
>>>>> they go; I checked the event log, but they are not there. Are they
>>>>> logged anywhere? If not, why are they there to begin with?
>>>>>
>>>>> Any other tip on how to effectively debug this stuff would be most
>>>>> welcome as well.
>>>> The print statements go into empty space because there is no stdout for
>>>> that process.  You can try using the logging module to log to a 
>>>> file, or
>>>> you can use ctypes to write to kernel32.OutputDebugString and using a
>>>> kernel debug log monitor to read them.
>>> The logging module reminds me of Java too much. :(  I think I'll try to
>>> write to a file, I have no idea if I have a kernel debug log monitor.
>>
>> For stuff like this you should look around at the sysinternals site.  
>> They have
>> a DebugView utility that displays these log strings.  ProcessExplorer 
>> is also
>> a very nice and useful replacement or addition for the task manager.
> 
> I second the sysinternals visit. But just in case you fancy the
> exercise, you can use Python to trap OutputDebugString calls:
> 
> http://timgolden.me.uk/python/win32_how_do_i/capture-OutputDebugString.html


And also the win32traceutil facility which comes with the pywin32
extensions can help you out here. If you import win32traceutil in
any module, sys.stdout (and maybe stderr) is redirected to a pipe
which is picked up by running the win32traceutil module as a script:

python -mwin32traceutil

Insanely helpful when you're trying to debug, an ISAPI extension
module.

TJG


More information about the python-win32 mailing list