remove unccessary code from pdb plugin
--HG-- branch : trunk
This commit is contained in:
parent
94c2fd4033
commit
60a9b60634
|
@ -2,7 +2,7 @@
|
||||||
interactive debugging with the Python Debugger.
|
interactive debugging with the Python Debugger.
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
import bdb, pdb, sys, linecache
|
import sys
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.getgroup("general")
|
group = parser.getgroup("general")
|
||||||
|
@ -21,7 +21,7 @@ class PdbInvoke:
|
||||||
def pytest_runtest_makereport(self, item, call, __multicall__):
|
def pytest_runtest_makereport(self, item, call, __multicall__):
|
||||||
if not call.excinfo or \
|
if not call.excinfo or \
|
||||||
call.excinfo.errisinstance(py.test.skip.Exception) or \
|
call.excinfo.errisinstance(py.test.skip.Exception) or \
|
||||||
call.excinfo.errisinstance(bdb.BdbQuit):
|
call.excinfo.errisinstance(py.std.bdb.BdbQuit):
|
||||||
return
|
return
|
||||||
rep = __multicall__.execute()
|
rep = __multicall__.execute()
|
||||||
if "xfail" in rep.keywords:
|
if "xfail" in rep.keywords:
|
||||||
|
@ -35,77 +35,16 @@ class PdbInvoke:
|
||||||
post_mortem(call.excinfo._excinfo[2])
|
post_mortem(call.excinfo._excinfo[2])
|
||||||
return rep
|
return rep
|
||||||
|
|
||||||
class Pdb(py.std.pdb.Pdb):
|
def post_mortem(t):
|
||||||
def do_list(self, arg):
|
pdb = py.std.pdb
|
||||||
self.lastcmd = 'list'
|
class Pdb(pdb.Pdb):
|
||||||
last = None
|
|
||||||
if arg:
|
|
||||||
try:
|
|
||||||
x = eval(arg, {}, {})
|
|
||||||
if type(x) == type(()):
|
|
||||||
first, last = x
|
|
||||||
first = int(first)
|
|
||||||
last = int(last)
|
|
||||||
if last < first:
|
|
||||||
# Assume it's a count
|
|
||||||
last = first + last
|
|
||||||
else:
|
|
||||||
first = max(1, int(x) - 5)
|
|
||||||
except:
|
|
||||||
print ('*** Error in argument: %s' % repr(arg))
|
|
||||||
return
|
|
||||||
elif self.lineno is None:
|
|
||||||
first = max(1, self.curframe.f_lineno - 5)
|
|
||||||
else:
|
|
||||||
first = self.lineno + 1
|
|
||||||
if last is None:
|
|
||||||
last = first + 10
|
|
||||||
filename = self.curframe.f_code.co_filename
|
|
||||||
breaklist = self.get_file_breaks(filename)
|
|
||||||
try:
|
|
||||||
for lineno in range(first, last+1):
|
|
||||||
# start difference from normal do_line
|
|
||||||
line = self._getline(filename, lineno)
|
|
||||||
# end difference from normal do_line
|
|
||||||
if not line:
|
|
||||||
print ('[EOF]')
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
s = repr(lineno).rjust(3)
|
|
||||||
if len(s) < 4: s = s + ' '
|
|
||||||
if lineno in breaklist: s = s + 'B'
|
|
||||||
else: s = s + ' '
|
|
||||||
if lineno == self.curframe.f_lineno:
|
|
||||||
s = s + '->'
|
|
||||||
sys.stdout.write(s + '\t' + line)
|
|
||||||
self.lineno = lineno
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
do_l = do_list
|
|
||||||
|
|
||||||
def _getline(self, filename, lineno):
|
|
||||||
if hasattr(filename, "__source__"):
|
|
||||||
try:
|
|
||||||
return filename.__source__.lines[lineno - 1] + "\n"
|
|
||||||
except IndexError:
|
|
||||||
return None
|
|
||||||
return linecache.getline(filename, lineno)
|
|
||||||
|
|
||||||
def get_stack(self, f, t):
|
def get_stack(self, f, t):
|
||||||
# Modified from bdb.py to be able to walk the stack beyond generators,
|
|
||||||
# which does not work in the normal pdb :-(
|
|
||||||
stack, i = pdb.Pdb.get_stack(self, f, t)
|
stack, i = pdb.Pdb.get_stack(self, f, t)
|
||||||
if f is None:
|
if f is None:
|
||||||
i = max(0, len(stack) - 1)
|
i = max(0, len(stack) - 1)
|
||||||
while i and stack[i][0].f_locals.get("__tracebackhide__", False):
|
while i and stack[i][0].f_locals.get("__tracebackhide__", False):
|
||||||
i-=1
|
i-=1
|
||||||
return stack, i
|
return stack, i
|
||||||
|
|
||||||
def post_mortem(t):
|
|
||||||
p = Pdb()
|
p = Pdb()
|
||||||
p.reset()
|
p.reset()
|
||||||
p.interaction(None, t)
|
p.interaction(None, t)
|
||||||
|
|
||||||
def set_trace():
|
|
||||||
# again, a copy of the version in pdb.py
|
|
||||||
Pdb().set_trace(sys._getframe().f_back)
|
|
||||||
|
|
Loading…
Reference in New Issue