@@ -697,9 +697,9 @@ def _complete(self, text, state):
697697 self ._completions = []
698698
699699 # Get completions from fancycompleter.
700- mydict = self .curframe .f_globals .copy ()
701- mydict .update (self .curframe_locals )
702- completer = Completer (mydict )
700+ f_globals = self .curframe .f_globals .copy ()
701+ f_globals .update (self .curframe_locals )
702+ completer = Completer (f_globals )
703703 completions = self ._get_all_completions (completer .complete , text )
704704
705705 if self .fancycompleter .config .use_colors :
@@ -1078,6 +1078,23 @@ def default(self, line):
10781078 exc_info = sys .exc_info ()[:2 ]
10791079 self .error (traceback .format_exception_only (* exc_info )[- 1 ].strip ())
10801080
1081+ @property
1082+ def curframe_locals (self ):
1083+ # deprecated in 3.13+
1084+ # See https://github.com/python/cpython/pull/125951/files
1085+ if sys .version_info >= (3 , 13 ):
1086+ return self .curframe .f_locals if self .curframe else {}
1087+
1088+ return getattr (self , "_curframe_locals" , {})
1089+
1090+ @curframe_locals .setter
1091+ def curframe_locals (self , value ):
1092+ if sys .version_info >= (3 , 13 ):
1093+ # no need to set this, it was just a cache for self.curframe.f_locals
1094+ return
1095+
1096+ self ._curframe_locals = value
1097+
10811098 def do_help (self , arg ):
10821099 try :
10831100 return super ().do_help (arg )
0 commit comments