--- c:\Python27\Lib\pdb.py Tue Mar 08 09:43:16 2011 +++ pdb.py Wed Nov 02 10:53:26 2011 @@ -355,6 +355,7 @@ filename = None lineno = None cond = None + globs = None comma = arg.find(',') if comma > 0: # parse stuff after comma: "condition" @@ -393,6 +394,7 @@ if hasattr(func, 'im_func'): func = func.im_func code = func.func_code + globs = func.func_globals #use co_name to identify the bkpt (function names #could be aliased, but co_name is invariant) funcname = code.co_name @@ -409,10 +411,12 @@ return funcname = ok # ok contains a function name lineno = int(ln) + else: + globs = self.curframe.f_globals if not filename: filename = self.defaultFile() # Check for reasonable breakpoint - line = self.checkline(filename, lineno) + line = self.checkline(filename, lineno, globs) if line: # now set the break point err = self.set_break(filename, line, temporary, cond, funcname) @@ -469,16 +473,13 @@ answer = find_function(item, fname) return answer or failed - def checkline(self, filename, lineno): + def checkline(self, filename, lineno, module_globals=None): """Check whether specified line seems to be executable. Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank line or EOF). Warning: testing is not comprehensive. """ - # this method should be callable before starting debugging, so default - # to "no globals" if there is no current frame - globs = self.curframe.f_globals if hasattr(self, 'curframe') else None - line = linecache.getline(filename, lineno, globs) + line = linecache.getline(self.canonic(filename), lineno, module_globals) if not line: print >>self.stdout, 'End of file' return 0 @@ -807,7 +808,7 @@ breaklist = self.get_file_breaks(filename) try: for lineno in range(first, last+1): - line = linecache.getline(filename, lineno, + line = linecache.getline(self.canonic(filename), lineno, self.curframe.f_globals) if not line: print >>self.stdout, '[EOF]'