There was an error while loading. Please reload this page.
1 parent a486d45 commit 4885ecfCopy full SHA for 4885ecf
2 files changed
Lib/pdb.py
@@ -398,6 +398,12 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
398
399
self._current_task = None
400
401
+ self.lineno = None
402
+ self.stack = []
403
+ self.curindex = 0
404
+ self.curframe = None
405
+ self._user_requested_quit = False
406
+
407
def set_trace(self, frame=None, *, commands=None):
408
Pdb._last_pdb_instance = self
409
if frame is None:
@@ -474,7 +480,7 @@ def forget(self):
474
480
self.lineno = None
475
481
self.stack = []
476
482
self.curindex = 0
477
- if hasattr(self, 'curframe') and self.curframe:
483
+ if self.curframe:
478
484
self.curframe.f_globals.pop('__pdb_convenience_variables', None)
479
485
self.curframe = None
486
self.tb_lineno.clear()
@@ -1493,7 +1499,7 @@ def checkline(self, filename, lineno, module_globals=None):
1493
1499
"""
1494
1500
# this method should be callable before starting debugging, so default
1495
1501
# to "no globals" if there is no current frame
1496
- frame = getattr(self, 'curframe', None)
1502
+ frame = self.curframe
1497
1503
if module_globals is None:
1498
1504
module_globals = frame.f_globals if frame else None
1505
line = linecache.getline(filename, lineno, module_globals)
Misc/NEWS.d/next/Library/2025-10-30-12-36-19.gh-issue-140790._3T6-N.rst
@@ -0,0 +1 @@
1
+Initialize all Pdb's instance variables in ``__init__``, remove some hasattr/getattr
0 commit comments