Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: pdb.py
#! /usr/bin/python2.7
[0] Fix | Delete
[1] Fix | Delete
"""A Python debugger."""
[2] Fix | Delete
[3] Fix | Delete
# (See pdb.doc for documentation.)
[4] Fix | Delete
[5] Fix | Delete
import sys
[6] Fix | Delete
import linecache
[7] Fix | Delete
import cmd
[8] Fix | Delete
import bdb
[9] Fix | Delete
from repr import Repr
[10] Fix | Delete
import os
[11] Fix | Delete
import re
[12] Fix | Delete
import pprint
[13] Fix | Delete
import traceback
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
class Restart(Exception):
[17] Fix | Delete
"""Causes a debugger to be restarted for the debugged python program."""
[18] Fix | Delete
pass
[19] Fix | Delete
[20] Fix | Delete
# Create a custom safe Repr instance and increase its maxstring.
[21] Fix | Delete
# The default of 30 truncates error messages too easily.
[22] Fix | Delete
_repr = Repr()
[23] Fix | Delete
_repr.maxstring = 200
[24] Fix | Delete
_saferepr = _repr.repr
[25] Fix | Delete
[26] Fix | Delete
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
[27] Fix | Delete
"post_mortem", "help"]
[28] Fix | Delete
[29] Fix | Delete
def find_function(funcname, filename):
[30] Fix | Delete
cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
[31] Fix | Delete
try:
[32] Fix | Delete
fp = open(filename)
[33] Fix | Delete
except IOError:
[34] Fix | Delete
return None
[35] Fix | Delete
# consumer of this info expects the first line to be 1
[36] Fix | Delete
lineno = 1
[37] Fix | Delete
answer = None
[38] Fix | Delete
while 1:
[39] Fix | Delete
line = fp.readline()
[40] Fix | Delete
if line == '':
[41] Fix | Delete
break
[42] Fix | Delete
if cre.match(line):
[43] Fix | Delete
answer = funcname, filename, lineno
[44] Fix | Delete
break
[45] Fix | Delete
lineno = lineno + 1
[46] Fix | Delete
fp.close()
[47] Fix | Delete
return answer
[48] Fix | Delete
[49] Fix | Delete
[50] Fix | Delete
# Interaction prompt line will separate file and call info from code
[51] Fix | Delete
# text using value of line_prefix string. A newline and arrow may
[52] Fix | Delete
# be to your liking. You can set it once pdb is imported using the
[53] Fix | Delete
# command "pdb.line_prefix = '\n% '".
[54] Fix | Delete
# line_prefix = ': ' # Use this to get the old situation back
[55] Fix | Delete
line_prefix = '\n-> ' # Probably a better default
[56] Fix | Delete
[57] Fix | Delete
class Pdb(bdb.Bdb, cmd.Cmd):
[58] Fix | Delete
[59] Fix | Delete
def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None):
[60] Fix | Delete
bdb.Bdb.__init__(self, skip=skip)
[61] Fix | Delete
cmd.Cmd.__init__(self, completekey, stdin, stdout)
[62] Fix | Delete
if stdout:
[63] Fix | Delete
self.use_rawinput = 0
[64] Fix | Delete
self.prompt = '(Pdb) '
[65] Fix | Delete
self.aliases = {}
[66] Fix | Delete
self.mainpyfile = ''
[67] Fix | Delete
self._wait_for_mainpyfile = 0
[68] Fix | Delete
# Try to load readline if it exists
[69] Fix | Delete
try:
[70] Fix | Delete
import readline
[71] Fix | Delete
except ImportError:
[72] Fix | Delete
pass
[73] Fix | Delete
[74] Fix | Delete
# Read $HOME/.pdbrc and ./.pdbrc
[75] Fix | Delete
self.rcLines = []
[76] Fix | Delete
if 'HOME' in os.environ:
[77] Fix | Delete
envHome = os.environ['HOME']
[78] Fix | Delete
try:
[79] Fix | Delete
rcFile = open(os.path.join(envHome, ".pdbrc"))
[80] Fix | Delete
except IOError:
[81] Fix | Delete
pass
[82] Fix | Delete
else:
[83] Fix | Delete
for line in rcFile.readlines():
[84] Fix | Delete
self.rcLines.append(line)
[85] Fix | Delete
rcFile.close()
[86] Fix | Delete
try:
[87] Fix | Delete
rcFile = open(".pdbrc")
[88] Fix | Delete
except IOError:
[89] Fix | Delete
pass
[90] Fix | Delete
else:
[91] Fix | Delete
for line in rcFile.readlines():
[92] Fix | Delete
self.rcLines.append(line)
[93] Fix | Delete
rcFile.close()
[94] Fix | Delete
[95] Fix | Delete
self.commands = {} # associates a command list to breakpoint numbers
[96] Fix | Delete
self.commands_doprompt = {} # for each bp num, tells if the prompt
[97] Fix | Delete
# must be disp. after execing the cmd list
[98] Fix | Delete
self.commands_silent = {} # for each bp num, tells if the stack trace
[99] Fix | Delete
# must be disp. after execing the cmd list
[100] Fix | Delete
self.commands_defining = False # True while in the process of defining
[101] Fix | Delete
# a command list
[102] Fix | Delete
self.commands_bnum = None # The breakpoint number for which we are
[103] Fix | Delete
# defining a list
[104] Fix | Delete
[105] Fix | Delete
def reset(self):
[106] Fix | Delete
bdb.Bdb.reset(self)
[107] Fix | Delete
self.forget()
[108] Fix | Delete
[109] Fix | Delete
def forget(self):
[110] Fix | Delete
self.lineno = None
[111] Fix | Delete
self.stack = []
[112] Fix | Delete
self.curindex = 0
[113] Fix | Delete
self.curframe = None
[114] Fix | Delete
[115] Fix | Delete
def setup(self, f, t):
[116] Fix | Delete
self.forget()
[117] Fix | Delete
self.stack, self.curindex = self.get_stack(f, t)
[118] Fix | Delete
self.curframe = self.stack[self.curindex][0]
[119] Fix | Delete
# The f_locals dictionary is updated from the actual frame
[120] Fix | Delete
# locals whenever the .f_locals accessor is called, so we
[121] Fix | Delete
# cache it here to ensure that modifications are not overwritten.
[122] Fix | Delete
self.curframe_locals = self.curframe.f_locals
[123] Fix | Delete
self.execRcLines()
[124] Fix | Delete
[125] Fix | Delete
# Can be executed earlier than 'setup' if desired
[126] Fix | Delete
def execRcLines(self):
[127] Fix | Delete
if self.rcLines:
[128] Fix | Delete
# Make local copy because of recursion
[129] Fix | Delete
rcLines = self.rcLines
[130] Fix | Delete
# executed only once
[131] Fix | Delete
self.rcLines = []
[132] Fix | Delete
for line in rcLines:
[133] Fix | Delete
line = line[:-1]
[134] Fix | Delete
if len(line) > 0 and line[0] != '#':
[135] Fix | Delete
self.onecmd(line)
[136] Fix | Delete
[137] Fix | Delete
# Override Bdb methods
[138] Fix | Delete
[139] Fix | Delete
def user_call(self, frame, argument_list):
[140] Fix | Delete
"""This method is called when there is the remote possibility
[141] Fix | Delete
that we ever need to stop in this function."""
[142] Fix | Delete
if self._wait_for_mainpyfile:
[143] Fix | Delete
return
[144] Fix | Delete
if self.stop_here(frame):
[145] Fix | Delete
print >>self.stdout, '--Call--'
[146] Fix | Delete
self.interaction(frame, None)
[147] Fix | Delete
[148] Fix | Delete
def user_line(self, frame):
[149] Fix | Delete
"""This function is called when we stop or break at this line."""
[150] Fix | Delete
if self._wait_for_mainpyfile:
[151] Fix | Delete
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
[152] Fix | Delete
or frame.f_lineno<= 0):
[153] Fix | Delete
return
[154] Fix | Delete
self._wait_for_mainpyfile = 0
[155] Fix | Delete
if self.bp_commands(frame):
[156] Fix | Delete
self.interaction(frame, None)
[157] Fix | Delete
[158] Fix | Delete
def bp_commands(self,frame):
[159] Fix | Delete
"""Call every command that was set for the current active breakpoint
[160] Fix | Delete
(if there is one).
[161] Fix | Delete
[162] Fix | Delete
Returns True if the normal interaction function must be called,
[163] Fix | Delete
False otherwise."""
[164] Fix | Delete
# self.currentbp is set in bdb in Bdb.break_here if a breakpoint was hit
[165] Fix | Delete
if getattr(self, "currentbp", False) and \
[166] Fix | Delete
self.currentbp in self.commands:
[167] Fix | Delete
currentbp = self.currentbp
[168] Fix | Delete
self.currentbp = 0
[169] Fix | Delete
lastcmd_back = self.lastcmd
[170] Fix | Delete
self.setup(frame, None)
[171] Fix | Delete
for line in self.commands[currentbp]:
[172] Fix | Delete
self.onecmd(line)
[173] Fix | Delete
self.lastcmd = lastcmd_back
[174] Fix | Delete
if not self.commands_silent[currentbp]:
[175] Fix | Delete
self.print_stack_entry(self.stack[self.curindex])
[176] Fix | Delete
if self.commands_doprompt[currentbp]:
[177] Fix | Delete
self.cmdloop()
[178] Fix | Delete
self.forget()
[179] Fix | Delete
return
[180] Fix | Delete
return 1
[181] Fix | Delete
[182] Fix | Delete
def user_return(self, frame, return_value):
[183] Fix | Delete
"""This function is called when a return trap is set here."""
[184] Fix | Delete
if self._wait_for_mainpyfile:
[185] Fix | Delete
return
[186] Fix | Delete
frame.f_locals['__return__'] = return_value
[187] Fix | Delete
print >>self.stdout, '--Return--'
[188] Fix | Delete
self.interaction(frame, None)
[189] Fix | Delete
[190] Fix | Delete
def user_exception(self, frame, exc_info):
[191] Fix | Delete
"""This function is called if an exception occurs,
[192] Fix | Delete
but only if we are to stop at or just below this level."""
[193] Fix | Delete
if self._wait_for_mainpyfile:
[194] Fix | Delete
return
[195] Fix | Delete
exc_type, exc_value, exc_traceback = exc_info
[196] Fix | Delete
frame.f_locals['__exception__'] = exc_type, exc_value
[197] Fix | Delete
if type(exc_type) == type(''):
[198] Fix | Delete
exc_type_name = exc_type
[199] Fix | Delete
else: exc_type_name = exc_type.__name__
[200] Fix | Delete
print >>self.stdout, exc_type_name + ':', _saferepr(exc_value)
[201] Fix | Delete
self.interaction(frame, exc_traceback)
[202] Fix | Delete
[203] Fix | Delete
# General interaction function
[204] Fix | Delete
[205] Fix | Delete
def interaction(self, frame, traceback):
[206] Fix | Delete
self.setup(frame, traceback)
[207] Fix | Delete
self.print_stack_entry(self.stack[self.curindex])
[208] Fix | Delete
self.cmdloop()
[209] Fix | Delete
self.forget()
[210] Fix | Delete
[211] Fix | Delete
def displayhook(self, obj):
[212] Fix | Delete
"""Custom displayhook for the exec in default(), which prevents
[213] Fix | Delete
assignment of the _ variable in the builtins.
[214] Fix | Delete
"""
[215] Fix | Delete
# reproduce the behavior of the standard displayhook, not printing None
[216] Fix | Delete
if obj is not None:
[217] Fix | Delete
print repr(obj)
[218] Fix | Delete
[219] Fix | Delete
def default(self, line):
[220] Fix | Delete
if line[:1] == '!': line = line[1:]
[221] Fix | Delete
locals = self.curframe_locals
[222] Fix | Delete
globals = self.curframe.f_globals
[223] Fix | Delete
try:
[224] Fix | Delete
code = compile(line + '\n', '<stdin>', 'single')
[225] Fix | Delete
save_stdout = sys.stdout
[226] Fix | Delete
save_stdin = sys.stdin
[227] Fix | Delete
save_displayhook = sys.displayhook
[228] Fix | Delete
try:
[229] Fix | Delete
sys.stdin = self.stdin
[230] Fix | Delete
sys.stdout = self.stdout
[231] Fix | Delete
sys.displayhook = self.displayhook
[232] Fix | Delete
exec code in globals, locals
[233] Fix | Delete
finally:
[234] Fix | Delete
sys.stdout = save_stdout
[235] Fix | Delete
sys.stdin = save_stdin
[236] Fix | Delete
sys.displayhook = save_displayhook
[237] Fix | Delete
except:
[238] Fix | Delete
t, v = sys.exc_info()[:2]
[239] Fix | Delete
if type(t) == type(''):
[240] Fix | Delete
exc_type_name = t
[241] Fix | Delete
else: exc_type_name = t.__name__
[242] Fix | Delete
print >>self.stdout, '***', exc_type_name + ':', v
[243] Fix | Delete
[244] Fix | Delete
def precmd(self, line):
[245] Fix | Delete
"""Handle alias expansion and ';;' separator."""
[246] Fix | Delete
if not line.strip():
[247] Fix | Delete
return line
[248] Fix | Delete
args = line.split()
[249] Fix | Delete
while args[0] in self.aliases:
[250] Fix | Delete
line = self.aliases[args[0]]
[251] Fix | Delete
ii = 1
[252] Fix | Delete
for tmpArg in args[1:]:
[253] Fix | Delete
line = line.replace("%" + str(ii),
[254] Fix | Delete
tmpArg)
[255] Fix | Delete
ii = ii + 1
[256] Fix | Delete
line = line.replace("%*", ' '.join(args[1:]))
[257] Fix | Delete
args = line.split()
[258] Fix | Delete
# split into ';;' separated commands
[259] Fix | Delete
# unless it's an alias command
[260] Fix | Delete
if args[0] != 'alias':
[261] Fix | Delete
marker = line.find(';;')
[262] Fix | Delete
if marker >= 0:
[263] Fix | Delete
# queue up everything after marker
[264] Fix | Delete
next = line[marker+2:].lstrip()
[265] Fix | Delete
self.cmdqueue.append(next)
[266] Fix | Delete
line = line[:marker].rstrip()
[267] Fix | Delete
return line
[268] Fix | Delete
[269] Fix | Delete
def onecmd(self, line):
[270] Fix | Delete
"""Interpret the argument as though it had been typed in response
[271] Fix | Delete
to the prompt.
[272] Fix | Delete
[273] Fix | Delete
Checks whether this line is typed at the normal prompt or in
[274] Fix | Delete
a breakpoint command list definition.
[275] Fix | Delete
"""
[276] Fix | Delete
if not self.commands_defining:
[277] Fix | Delete
return cmd.Cmd.onecmd(self, line)
[278] Fix | Delete
else:
[279] Fix | Delete
return self.handle_command_def(line)
[280] Fix | Delete
[281] Fix | Delete
def handle_command_def(self,line):
[282] Fix | Delete
"""Handles one command line during command list definition."""
[283] Fix | Delete
cmd, arg, line = self.parseline(line)
[284] Fix | Delete
if not cmd:
[285] Fix | Delete
return
[286] Fix | Delete
if cmd == 'silent':
[287] Fix | Delete
self.commands_silent[self.commands_bnum] = True
[288] Fix | Delete
return # continue to handle other cmd def in the cmd list
[289] Fix | Delete
elif cmd == 'end':
[290] Fix | Delete
self.cmdqueue = []
[291] Fix | Delete
return 1 # end of cmd list
[292] Fix | Delete
cmdlist = self.commands[self.commands_bnum]
[293] Fix | Delete
if arg:
[294] Fix | Delete
cmdlist.append(cmd+' '+arg)
[295] Fix | Delete
else:
[296] Fix | Delete
cmdlist.append(cmd)
[297] Fix | Delete
# Determine if we must stop
[298] Fix | Delete
try:
[299] Fix | Delete
func = getattr(self, 'do_' + cmd)
[300] Fix | Delete
except AttributeError:
[301] Fix | Delete
func = self.default
[302] Fix | Delete
# one of the resuming commands
[303] Fix | Delete
if func.func_name in self.commands_resuming:
[304] Fix | Delete
self.commands_doprompt[self.commands_bnum] = False
[305] Fix | Delete
self.cmdqueue = []
[306] Fix | Delete
return 1
[307] Fix | Delete
return
[308] Fix | Delete
[309] Fix | Delete
# Command definitions, called by cmdloop()
[310] Fix | Delete
# The argument is the remaining string on the command line
[311] Fix | Delete
# Return true to exit from the command loop
[312] Fix | Delete
[313] Fix | Delete
do_h = cmd.Cmd.do_help
[314] Fix | Delete
[315] Fix | Delete
def do_commands(self, arg):
[316] Fix | Delete
"""Defines a list of commands associated to a breakpoint.
[317] Fix | Delete
[318] Fix | Delete
Those commands will be executed whenever the breakpoint causes
[319] Fix | Delete
the program to stop execution."""
[320] Fix | Delete
if not arg:
[321] Fix | Delete
bnum = len(bdb.Breakpoint.bpbynumber)-1
[322] Fix | Delete
else:
[323] Fix | Delete
try:
[324] Fix | Delete
bnum = int(arg)
[325] Fix | Delete
except:
[326] Fix | Delete
print >>self.stdout, "Usage : commands [bnum]\n ..." \
[327] Fix | Delete
"\n end"
[328] Fix | Delete
return
[329] Fix | Delete
self.commands_bnum = bnum
[330] Fix | Delete
self.commands[bnum] = []
[331] Fix | Delete
self.commands_doprompt[bnum] = True
[332] Fix | Delete
self.commands_silent[bnum] = False
[333] Fix | Delete
prompt_back = self.prompt
[334] Fix | Delete
self.prompt = '(com) '
[335] Fix | Delete
self.commands_defining = True
[336] Fix | Delete
try:
[337] Fix | Delete
self.cmdloop()
[338] Fix | Delete
finally:
[339] Fix | Delete
self.commands_defining = False
[340] Fix | Delete
self.prompt = prompt_back
[341] Fix | Delete
[342] Fix | Delete
def do_break(self, arg, temporary = 0):
[343] Fix | Delete
# break [ ([filename:]lineno | function) [, "condition"] ]
[344] Fix | Delete
if not arg:
[345] Fix | Delete
if self.breaks: # There's at least one
[346] Fix | Delete
print >>self.stdout, "Num Type Disp Enb Where"
[347] Fix | Delete
for bp in bdb.Breakpoint.bpbynumber:
[348] Fix | Delete
if bp:
[349] Fix | Delete
bp.bpprint(self.stdout)
[350] Fix | Delete
return
[351] Fix | Delete
# parse arguments; comma has lowest precedence
[352] Fix | Delete
# and cannot occur in filename
[353] Fix | Delete
filename = None
[354] Fix | Delete
lineno = None
[355] Fix | Delete
cond = None
[356] Fix | Delete
comma = arg.find(',')
[357] Fix | Delete
if comma > 0:
[358] Fix | Delete
# parse stuff after comma: "condition"
[359] Fix | Delete
cond = arg[comma+1:].lstrip()
[360] Fix | Delete
arg = arg[:comma].rstrip()
[361] Fix | Delete
# parse stuff before comma: [filename:]lineno | function
[362] Fix | Delete
colon = arg.rfind(':')
[363] Fix | Delete
funcname = None
[364] Fix | Delete
if colon >= 0:
[365] Fix | Delete
filename = arg[:colon].rstrip()
[366] Fix | Delete
f = self.lookupmodule(filename)
[367] Fix | Delete
if not f:
[368] Fix | Delete
print >>self.stdout, '*** ', repr(filename),
[369] Fix | Delete
print >>self.stdout, 'not found from sys.path'
[370] Fix | Delete
return
[371] Fix | Delete
else:
[372] Fix | Delete
filename = f
[373] Fix | Delete
arg = arg[colon+1:].lstrip()
[374] Fix | Delete
try:
[375] Fix | Delete
lineno = int(arg)
[376] Fix | Delete
except ValueError, msg:
[377] Fix | Delete
print >>self.stdout, '*** Bad lineno:', arg
[378] Fix | Delete
return
[379] Fix | Delete
else:
[380] Fix | Delete
# no colon; can be lineno or function
[381] Fix | Delete
try:
[382] Fix | Delete
lineno = int(arg)
[383] Fix | Delete
except ValueError:
[384] Fix | Delete
try:
[385] Fix | Delete
func = eval(arg,
[386] Fix | Delete
self.curframe.f_globals,
[387] Fix | Delete
self.curframe_locals)
[388] Fix | Delete
except:
[389] Fix | Delete
func = arg
[390] Fix | Delete
try:
[391] Fix | Delete
if hasattr(func, 'im_func'):
[392] Fix | Delete
func = func.im_func
[393] Fix | Delete
code = func.func_code
[394] Fix | Delete
#use co_name to identify the bkpt (function names
[395] Fix | Delete
#could be aliased, but co_name is invariant)
[396] Fix | Delete
funcname = code.co_name
[397] Fix | Delete
lineno = code.co_firstlineno
[398] Fix | Delete
filename = code.co_filename
[399] Fix | Delete
except:
[400] Fix | Delete
# last thing to try
[401] Fix | Delete
(ok, filename, ln) = self.lineinfo(arg)
[402] Fix | Delete
if not ok:
[403] Fix | Delete
print >>self.stdout, '*** The specified object',
[404] Fix | Delete
print >>self.stdout, repr(arg),
[405] Fix | Delete
print >>self.stdout, 'is not a function'
[406] Fix | Delete
print >>self.stdout, 'or was not found along sys.path.'
[407] Fix | Delete
return
[408] Fix | Delete
funcname = ok # ok contains a function name
[409] Fix | Delete
lineno = int(ln)
[410] Fix | Delete
if not filename:
[411] Fix | Delete
filename = self.defaultFile()
[412] Fix | Delete
# Check for reasonable breakpoint
[413] Fix | Delete
line = self.checkline(filename, lineno)
[414] Fix | Delete
if line:
[415] Fix | Delete
# now set the break point
[416] Fix | Delete
err = self.set_break(filename, line, temporary, cond, funcname)
[417] Fix | Delete
if err: print >>self.stdout, '***', err
[418] Fix | Delete
else:
[419] Fix | Delete
bp = self.get_breaks(filename, line)[-1]
[420] Fix | Delete
print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number,
[421] Fix | Delete
bp.file,
[422] Fix | Delete
bp.line)
[423] Fix | Delete
[424] Fix | Delete
# To be overridden in derived debuggers
[425] Fix | Delete
def defaultFile(self):
[426] Fix | Delete
"""Produce a reasonable default."""
[427] Fix | Delete
filename = self.curframe.f_code.co_filename
[428] Fix | Delete
if filename == '<string>' and self.mainpyfile:
[429] Fix | Delete
filename = self.mainpyfile
[430] Fix | Delete
return filename
[431] Fix | Delete
[432] Fix | Delete
do_b = do_break
[433] Fix | Delete
[434] Fix | Delete
def do_tbreak(self, arg):
[435] Fix | Delete
self.do_break(arg, 1)
[436] Fix | Delete
[437] Fix | Delete
def lineinfo(self, identifier):
[438] Fix | Delete
failed = (None, None, None)
[439] Fix | Delete
# Input is identifier, may be in single quotes
[440] Fix | Delete
idstring = identifier.split("'")
[441] Fix | Delete
if len(idstring) == 1:
[442] Fix | Delete
# not in single quotes
[443] Fix | Delete
id = idstring[0].strip()
[444] Fix | Delete
elif len(idstring) == 3:
[445] Fix | Delete
# quoted
[446] Fix | Delete
id = idstring[1].strip()
[447] Fix | Delete
else:
[448] Fix | Delete
return failed
[449] Fix | Delete
if id == '': return failed
[450] Fix | Delete
parts = id.split('.')
[451] Fix | Delete
# Protection for derived debuggers
[452] Fix | Delete
if parts[0] == 'self':
[453] Fix | Delete
del parts[0]
[454] Fix | Delete
if len(parts) == 0:
[455] Fix | Delete
return failed
[456] Fix | Delete
# Best first guess at file to look at
[457] Fix | Delete
fname = self.defaultFile()
[458] Fix | Delete
if len(parts) == 1:
[459] Fix | Delete
item = parts[0]
[460] Fix | Delete
else:
[461] Fix | Delete
# More than one part.
[462] Fix | Delete
# First is module, second is method/class
[463] Fix | Delete
f = self.lookupmodule(parts[0])
[464] Fix | Delete
if f:
[465] Fix | Delete
fname = f
[466] Fix | Delete
item = parts[1]
[467] Fix | Delete
answer = find_function(item, fname)
[468] Fix | Delete
return answer or failed
[469] Fix | Delete
[470] Fix | Delete
def checkline(self, filename, lineno):
[471] Fix | Delete
"""Check whether specified line seems to be executable.
[472] Fix | Delete
[473] Fix | Delete
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
[474] Fix | Delete
line or EOF). Warning: testing is not comprehensive.
[475] Fix | Delete
"""
[476] Fix | Delete
# this method should be callable before starting debugging, so default
[477] Fix | Delete
# to "no globals" if there is no current frame
[478] Fix | Delete
globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
[479] Fix | Delete
line = linecache.getline(filename, lineno, globs)
[480] Fix | Delete
if not line:
[481] Fix | Delete
print >>self.stdout, 'End of file'
[482] Fix | Delete
return 0
[483] Fix | Delete
line = line.strip()
[484] Fix | Delete
# Don't allow setting breakpoint at a blank line
[485] Fix | Delete
if (not line or (line[0] == '#') or
[486] Fix | Delete
(line[:3] == '"""') or line[:3] == "'''"):
[487] Fix | Delete
print >>self.stdout, '*** Blank or comment'
[488] Fix | Delete
return 0
[489] Fix | Delete
return lineno
[490] Fix | Delete
[491] Fix | Delete
def do_enable(self, arg):
[492] Fix | Delete
args = arg.split()
[493] Fix | Delete
for i in args:
[494] Fix | Delete
try:
[495] Fix | Delete
i = int(i)
[496] Fix | Delete
except ValueError:
[497] Fix | Delete
print >>self.stdout, 'Breakpoint index %r is not a number' % i
[498] Fix | Delete
continue
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function