Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4d8273

Browse files
committed
handle curframe_locals deprecation in 3.14
- python/cpython#124369 - python/cpython#125951
1 parent 7912eab commit e4d8273

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

src/pdbpp.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,29 @@ 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
1087+
1088+
return self._curframe_locals
1089+
1090+
@curframe_locals.setter
1091+
def curframe_locals(self, value):
1092+
if sys.version_info >= (3, 13):
1093+
if not hasattr(self.curframe, "f_locals"):
1094+
self.curframe.f_locals = value
1095+
else:
1096+
self.curframe.f_locals.update(value)
1097+
return
1098+
1099+
if not hasattr(self, "_curframe_locals"):
1100+
self._curframe_locals = value
1101+
else:
1102+
self._curframe_locals.update(value)
1103+
10811104
def do_help(self, arg):
10821105
try:
10831106
return super().do_help(arg)

0 commit comments

Comments
 (0)