[Python.NET] Problem debugging to python.runtime.dll

Barton barton at BCDesignsWell.com
Mon Jul 5 22:04:16 CEST 2010

>  Vishal.Parikh wrote:
/>>/  We are actually using Python.Net with python 2.5 and I wanted to learn
/>>/  the internal architecture of the Python.Runtime.Dll. I have tried
/>>/  debugging the dll by attaching the process to python.exe but doesn't hit
/>>/  any break point. I don't know much about the compiler design and how it
/>>/  works internal but all I want is I should be able to debug how my C#
/>>/  instruction is getting executed using python.runtime.dll
>/  /In the Debug Tab of the Properties dialog for your C# project choose "Start
>/  /external program" for the Start Action and select the normal CPython
>  executable - python.exe. In the "Command line arguments" put the full path
>  of the python script which calls the C# function you want to debug. If you
>  debug the project now it should run the python script and you should drop in
>  to the c# debugger at the breakpoint you set in the function called by the
>  Python script.
>  HTH,
>  Dave

It's been pretty quiet on the list lately, so I post a couple of helpful tips:

Instead of using the "normal CPython" executable, I find it useful to choose
[PathToSolution]/python.exe which is a Managed Code way of loading the pythonxx.dll
and allows you to step out of the interpreter main loop when your script exits.

Using a cool IDE (like Boa Constructor) which lets you set the interpreter, I
also choose [PathToSolution]/python.exe.  This makes running [PathToProject]/src/tests/runtests.py
(which imports the Pythnon.Test managed test assembly) a snap!

This all works thanks to the Post-build event command line of the projects:
call "$(ProjectDir)buildclrmodule.bat" $(Platform) "$(ProjectDir)" "$(TargetDir)clr.pyd"
copy "$(TargetPath)" "$(SolutionDir)"
copy "$(TargetDir)*.pdb" "$(SolutionDir)"
copy "$(TargetDir)clr.pyd" "$(SolutionDir)"

copy "$(TargetPath)" "$(SolutionDir)"
copy "$(TargetDir)*.pdb" "$(SolutionDir)"

Speaking of runtests.py, it still doesn't run to completion.  I'll be working on
the Int64 issue shortly.

Windows 7
Python 2.6

More information about the PythonDotNet mailing list