@@ -403,13 +403,6 @@ def setup(self, f, tb):
403
403
self .tb_lineno [tb .tb_frame ] = lineno
404
404
tb = tb .tb_next
405
405
self .curframe = self .stack [self .curindex ][0 ]
406
- # The f_locals dictionary used to be updated from the actual frame
407
- # locals whenever the .f_locals accessor was called, so it was
408
- # cached here to ensure that modifications were not overwritten. While
409
- # the caching is no longer required now that f_locals is a direct proxy
410
- # on optimized frames, it's also harmless, so the code structure has
411
- # been left unchanged.
412
- self .curframe_locals = self .curframe .f_locals
413
406
self .set_convenience_variable (self .curframe , '_frame' , self .curframe )
414
407
415
408
if self ._chained_exceptions :
@@ -732,7 +725,7 @@ def _exec_in_closure(self, source, globals, locals):
732
725
733
726
def default (self , line ):
734
727
if line [:1 ] == '!' : line = line [1 :].strip ()
735
- locals = self .curframe_locals
728
+ locals = self .curframe . f_locals
736
729
globals = self .curframe .f_globals
737
730
try :
738
731
buffer = line
@@ -960,7 +953,7 @@ def _complete_expression(self, text, line, begidx, endidx):
960
953
# Collect globals and locals. It is usually not really sensible to also
961
954
# complete builtins, and they clutter the namespace quite heavily, so we
962
955
# leave them out.
963
- ns = {** self .curframe .f_globals , ** self .curframe_locals }
956
+ ns = {** self .curframe .f_globals , ** self .curframe . f_locals }
964
957
if text .startswith ("$" ):
965
958
# Complete convenience variables
966
959
conv_vars = self .curframe .f_globals .get ('__pdb_convenience_variables' , {})
@@ -991,7 +984,7 @@ def completedefault(self, text, line, begidx, endidx):
991
984
# Use rlcompleter to do the completion
992
985
state = 0
993
986
matches = []
994
- completer = Completer (self .curframe .f_globals | self .curframe_locals )
987
+ completer = Completer (self .curframe .f_globals | self .curframe . f_locals )
995
988
while (match := completer .complete (text , state )) is not None :
996
989
matches .append (match )
997
990
state += 1
@@ -1153,7 +1146,7 @@ def do_break(self, arg, temporary = 0):
1153
1146
try :
1154
1147
func = eval (arg ,
1155
1148
self .curframe .f_globals ,
1156
- self .curframe_locals )
1149
+ self .curframe . f_locals )
1157
1150
except :
1158
1151
func = arg
1159
1152
try :
@@ -1458,7 +1451,6 @@ def _select_frame(self, number):
1458
1451
assert 0 <= number < len (self .stack )
1459
1452
self .curindex = number
1460
1453
self .curframe = self .stack [self .curindex ][0 ]
1461
- self .curframe_locals = self .curframe .f_locals
1462
1454
self .set_convenience_variable (self .curframe , '_frame' , self .curframe )
1463
1455
self .print_stack_entry (self .stack [self .curindex ])
1464
1456
self .lineno = None
@@ -1704,7 +1696,7 @@ def do_debug(self, arg):
1704
1696
"""
1705
1697
sys .settrace (None )
1706
1698
globals = self .curframe .f_globals
1707
- locals = self .curframe_locals
1699
+ locals = self .curframe . f_locals
1708
1700
p = Pdb (self .completekey , self .stdin , self .stdout )
1709
1701
p .prompt = "(%s) " % self .prompt .strip ()
1710
1702
self .message ("ENTERING RECURSIVE DEBUGGER" )
@@ -1749,7 +1741,7 @@ def do_args(self, arg):
1749
1741
self ._print_invalid_arg (arg )
1750
1742
return
1751
1743
co = self .curframe .f_code
1752
- dict = self .curframe_locals
1744
+ dict = self .curframe . f_locals
1753
1745
n = co .co_argcount + co .co_kwonlyargcount
1754
1746
if co .co_flags & inspect .CO_VARARGS : n = n + 1
1755
1747
if co .co_flags & inspect .CO_VARKEYWORDS : n = n + 1
@@ -1769,23 +1761,23 @@ def do_retval(self, arg):
1769
1761
if arg :
1770
1762
self ._print_invalid_arg (arg )
1771
1763
return
1772
- if '__return__' in self .curframe_locals :
1773
- self .message (self ._safe_repr (self .curframe_locals ['__return__' ], "retval" ))
1764
+ if '__return__' in self .curframe . f_locals :
1765
+ self .message (self ._safe_repr (self .curframe . f_locals ['__return__' ], "retval" ))
1774
1766
else :
1775
1767
self .error ('Not yet returned!' )
1776
1768
do_rv = do_retval
1777
1769
1778
1770
def _getval (self , arg ):
1779
1771
try :
1780
- return eval (arg , self .curframe .f_globals , self .curframe_locals )
1772
+ return eval (arg , self .curframe .f_globals , self .curframe . f_locals )
1781
1773
except :
1782
1774
self ._error_exc ()
1783
1775
raise
1784
1776
1785
1777
def _getval_except (self , arg , frame = None ):
1786
1778
try :
1787
1779
if frame is None :
1788
- return eval (arg , self .curframe .f_globals , self .curframe_locals )
1780
+ return eval (arg , self .curframe .f_globals , self .curframe . f_locals )
1789
1781
else :
1790
1782
return eval (arg , frame .f_globals , frame .f_locals )
1791
1783
except BaseException as exc :
@@ -2029,7 +2021,7 @@ def do_interact(self, arg):
2029
2021
Start an interactive interpreter whose global namespace
2030
2022
contains all the (global and local) names found in the current scope.
2031
2023
"""
2032
- ns = {** self .curframe .f_globals , ** self .curframe_locals }
2024
+ ns = {** self .curframe .f_globals , ** self .curframe . f_locals }
2033
2025
console = _PdbInteractiveConsole (ns , message = self .message )
2034
2026
console .interact (banner = "*pdb interact start*" ,
2035
2027
exitmsg = "*exit from pdb interact command*" )
0 commit comments