我试着调试一个sconstruct文件,这个文件已经深入到某个模糊的函数中,我想单步执行代码。我就是这么做的,但失败了:
$ python -m pdb `which scons.py`
> c:\python27\scripts\scons.py(26)<module>()
-> __revision__ = "src/script/scons.py 5357 2011/09/09 21:31:03 bdeegan"
(Pdb) b SConstruct:10
*** 'SConstruct' not found from sys.path
(Pdb) import sys, os
(Pdb) sys.path.append(os.getcwd())
(Pdb) b SConstruct:10
*** 'SConstruct' not found from sys.path
(Pdb)
如果我将sconstruct重命名为sconstruct.py,它将成功设置断点,但它当然不起作用,因为“scons”加载的是sconstruct,而不是sconstruct.py。
有没有办法强制python在那里设置断点?
我在win7系统上的msys bash控制台上运行这个。
Python版本:
$ python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
最佳答案
有一些关于Debugging SCons wiki page的提示。明确地:
scons --debug=pdb <args...>
# from the wiki example: you can set a breakpoint on a file relative to sys.path
(Pdb) b SCons/Tool/msvc.py:158
# you can set a breakpoint in the SConstruct file with the full path
(Pdb) b /Users/me/code/project/SConstruct:10
关于python - Win32上的scons:使用pdb调试SConstruct,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17957661/