我在使用virtualenv的 Mac 上ipython==0.13.2
和ipdb==0.7
内部也遇到了同样的现象。Python 2.7.5
当我尝试调试时,我有内置的选项卡完成,但不是当前范围内的变量。我发现,我有一个自定义.pdbrc
位于我的主文件夹(http://docs.python.org/2/library/pdb.html#id2)。在我将所有内容注释掉后,选项卡完成再次起作用。
我不知道我何时以及为什么添加此文件,但这就是其中的内容:
# See http://docs.python.org/2/library/pdb.html#id2 for the structure of this file.
import pdb
# 'inspect x' will print the source code for a method, class or function.
alias inspect import inspect;print inspect.getsource(%1)
alias i import inspect;print inspect.getsource(%1)
# 'help x' opens the man-style help viewer from the interpretter on an object
alias help !print help(%1)
alias h !print help(%1)
# For ordinary Python objects, ppo will pretty-print members and their values.
alias ppo pp %1.__dict__
# ppio runs ppo over a sequence of objects
alias ppio pp [a.__dict__ for a in %1]
# This tries to enable tab-completion of some identifiers.
!import rlcompleter
!pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Taken from https://gist.github.com/1125049
# There are a couple of edge cases where you can lose terminal
# echo. This should restore it next time you open a pdb.
!import termios, sys
!termios_fd = sys.stdin.fileno()
!termios_echo = termios.tcgetattr(termios_fd)
!termios_echo[3] = termios_echo[3] | termios.ECHO
!termios_result = termios.tcsetattr(termios_fd, termios.TCSADRAIN, termios_echo)
需要进一步的研究来检查是什么破坏了那里的制表符完成......