bpo-28528: Fix pdb.checkline() attribute error when 'curframe' is None. (GH-25438) (#26050)
Co-authored-by: Thomas Kluyver <takowl@gmail.com>
(cherry picked from commit 8563a7052ccd98e6a381d361664ce567afd5eb6e)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 98dc975..a888a0a 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -752,7 +752,8 @@ def checkline(self, filename, lineno):
"""
# this method should be callable before starting debugging, so default
# to "no globals" if there is no current frame
- globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
+ frame = getattr(self, 'curframe', None)
+ globs = frame.f_globals if frame else None
line = linecache.getline(filename, lineno, globs)
if not line:
self.message('End of file')