# HG changeset patch # User maru.newby # Date 1238625303 14400 # Branch trunk # Node ID cbbe6bd85e4986436827501df4b010b681e348c6 # Parent b3a81d9de1489d93ef28653b14b3795b5b152002 Fixed #5215 - The f_locals dict is now cached during traceback to ensure that user changes are not lost. diff -r b3a81d9de148 -r cbbe6bd85e49 Lib/pdb.py --- a/Lib/pdb.py Wed Apr 01 01:46:48 2009 +0200 +++ b/Lib/pdb.py Wed Apr 01 18:35:03 2009 -0400 @@ -114,6 +114,10 @@ self.forget() self.stack, self.curindex = self.get_stack(f, t) self.curframe = self.stack[self.curindex][0] + # The f_locals dictionary is updated from the actual frame + # locals when the .f_locals accessor is called so we cache it + # here to ensure that modifications are not overwritten. + self.curframe_locals = self.curframe.f_locals self.execRcLines() # Can be executed earlier than 'setup' if desired @@ -196,7 +200,7 @@ def default(self, line): if line[:1] == '!': line = line[1:] - locals = self.curframe.f_locals + locals = self.curframe_locals globals = self.curframe.f_globals try: code = compile(line + '\n', '', 'single') @@ -351,7 +355,7 @@ try: func = eval(arg, self.curframe.f_globals, - self.curframe.f_locals) + self.curframe_locals) except: func = arg try: @@ -672,7 +676,7 @@ def do_debug(self, arg): sys.settrace(None) globals = self.curframe.f_globals - locals = self.curframe.f_locals + locals = self.curframe_locals p = Pdb(self.completekey, self.stdin, self.stdout) p.prompt = "(%s) " % self.prompt.strip() print >>self.stdout, "ENTERING RECURSIVE DEBUGGER" @@ -698,7 +702,7 @@ def do_args(self, arg): f = self.curframe co = f.f_code - dict = f.f_locals + dict = self.curframe_locals n = co.co_argcount if co.co_flags & 4: n = n+1 if co.co_flags & 8: n = n+1 @@ -710,8 +714,8 @@ do_a = do_args def do_retval(self, arg): - if '__return__' in self.curframe.f_locals: - print >>self.stdout, self.curframe.f_locals['__return__'] + if '__return__' in self.curframe_locals: + print >>self.stdout, self.curframe_locals['__return__'] else: print >>self.stdout, '*** Not yet returned!' do_rv = do_retval @@ -719,7 +723,7 @@ def _getval(self, arg): try: return eval(arg, self.curframe.f_globals, - self.curframe.f_locals) + self.curframe_locals) except: t, v = sys.exc_info()[:2] if isinstance(t, str): @@ -788,7 +792,7 @@ def do_whatis(self, arg): try: value = eval(arg, self.curframe.f_globals, - self.curframe.f_locals) + self.curframe_locals) except: t, v = sys.exc_info()[:2] if type(t) == type(''):