##// END OF EJS Templates
Don't access current_frame f_locals...
Matthias Bussonnier -
Show More
@@ -331,7 +331,7 b' class Pdb(OldPdb):'
331 if frame in (self.curframe, getattr(self, "initial_frame", None)):
331 if frame in (self.curframe, getattr(self, "initial_frame", None)):
332 return False
332 return False
333 else:
333 else:
334 return frame.f_locals.get("__tracebackhide__", False)
334 return self._get_frame_locals(frame).get("__tracebackhide__", False)
335
335
336 return False
336 return False
337
337
@@ -435,6 +435,28 b' class Pdb(OldPdb):'
435 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
435 self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
436 # vds: <<
436 # vds: <<
437
437
438 def _get_frame_locals(self, frame):
439 """ "
440 Acessing f_local of current frame reset the namespace, so we want to avoid
441 that or the following can happend
442
443 ipdb> foo
444 "old"
445 ipdb> foo = "new"
446 ipdb> foo
447 "new"
448 ipdb> where
449 ipdb> foo
450 "old"
451
452 So if frame is self.current_frame we instead return self.curframe_locals
453
454 """
455 if frame is self.curframe:
456 return self.curframe_locals
457 else:
458 return frame.f_locals
459
438 def format_stack_entry(self, frame_lineno, lprefix=': ', context=None):
460 def format_stack_entry(self, frame_lineno, lprefix=': ', context=None):
439 if context is None:
461 if context is None:
440 context = self.context
462 context = self.context
@@ -459,10 +481,11 b' class Pdb(OldPdb):'
459 frame, lineno = frame_lineno
481 frame, lineno = frame_lineno
460
482
461 return_value = ''
483 return_value = ''
462 if '__return__' in frame.f_locals:
484 loc_frame = self._get_frame_locals(frame)
463 rv = frame.f_locals['__return__']
485 if "__return__" in loc_frame:
464 #return_value += '->'
486 rv = loc_frame["__return__"]
465 return_value += reprlib.repr(rv) + '\n'
487 # return_value += '->'
488 return_value += reprlib.repr(rv) + "\n"
466 ret.append(return_value)
489 ret.append(return_value)
467
490
468 #s = filename + '(' + `lineno` + ')'
491 #s = filename + '(' + `lineno` + ')'
@@ -474,10 +497,10 b' class Pdb(OldPdb):'
474 else:
497 else:
475 func = "<lambda>"
498 func = "<lambda>"
476
499
477 call = ''
500 call = ""
478 if func != '?':
501 if func != "?":
479 if '__args__' in frame.f_locals:
502 if "__args__" in loc_frame:
480 args = reprlib.repr(frame.f_locals['__args__'])
503 args = reprlib.repr(loc_frame["__args__"])
481 else:
504 else:
482 args = '()'
505 args = '()'
483 call = tpl_call % (func, args)
506 call = tpl_call % (func, args)
@@ -671,7 +694,7 b' class Pdb(OldPdb):'
671
694
672 def getsourcelines(self, obj):
695 def getsourcelines(self, obj):
673 lines, lineno = inspect.findsource(obj)
696 lines, lineno = inspect.findsource(obj)
674 if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
697 if inspect.isframe(obj) and obj.f_globals is self._get_frame_locals(obj):
675 # must be a module frame: do not try to cut a block out of it
698 # must be a module frame: do not try to cut a block out of it
676 return lines, 1
699 return lines, 1
677 elif inspect.ismodule(obj):
700 elif inspect.ismodule(obj):
General Comments 0
You need to be logged in to leave comments. Login now