1

我正在尝试调试一个 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 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.
4

1 回答 1

3

Debugging SCons wiki 页面上有一些提示。具体来说:

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
于 2013-07-31T06:01:32.053 回答