Debugging extensions under VS .NET 2003

Gus Tabares gustabares at verizon.net
Fri Apr 9 18:27:07 CEST 2004


This purpose of this post is to give a mini how-to on debugging Python
extensions written in C under Visual Studio .NET 2003. Please feel
free to correct any mistakes I may have made. Please realize that this
is not a comprehensive guide to debugging Python extensions; this is
only knowledge from what I have experienced. I hope that these
instructions will be handy to anyone who is having trouble debugging
Python extensions in a .NET 2003 environment.

If you want to be able to debug your extensions, you will to build a
debug version of the Python interpreter. The Python sources are freely
available on python.org.

You shouldn't need to build the entire Python environment, which
includes downloading openssl (and other) sources. Your main concern is
with the python project file.

After you compile the python project file, you should have the
following sets of files: python_d.exe (the debug interpreter),
python23_d.dll, python23_d.lib. You will need the .lib to link against
your debug extension.

Compile and link a debug version of your extension, making sure to
link against python23_d.lib. Also make sure that your extension is
named in the following format: pydname_d.pyd.  The _d is necessary
when importing from the debug interpreter.

Set your breakpoints in your extension code from within .NET. Make
sure the debug command is the full path to debug version of the Python
interpreter.

It should bring up the debug interpreter when you start debugging.
>From there you should be able to import your debug extension and
step-through your code from within .NET.

For more information and some examples, check out the readme file
located in the PC\example_nt directory of the Python sources. Note
that those instructions were written for Visual Studio 6 and not
specifically for .NET 2003.

Good luck,
Gus Tabares



More information about the Python-list mailing list