mirror of
https://github.com/python/cpython.git
synced 2026-03-30 08:30:57 +00:00
gh-140790: pdb: Initialize instance variables in Pdb.__init__ (#140791)
Initialize lineno, stack, curindex, curframe, currentbp, and _user_requested_quit attributes in `Pdb.__init__``.
This commit is contained in:
parent
a486d452c7
commit
4885ecfbda
2 changed files with 9 additions and 2 deletions
10
Lib/pdb.py
10
Lib/pdb.py
|
|
@ -398,6 +398,12 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
|
|||
|
||||
self._current_task = None
|
||||
|
||||
self.lineno = None
|
||||
self.stack = []
|
||||
self.curindex = 0
|
||||
self.curframe = None
|
||||
self._user_requested_quit = False
|
||||
|
||||
def set_trace(self, frame=None, *, commands=None):
|
||||
Pdb._last_pdb_instance = self
|
||||
if frame is None:
|
||||
|
|
@ -474,7 +480,7 @@ def forget(self):
|
|||
self.lineno = None
|
||||
self.stack = []
|
||||
self.curindex = 0
|
||||
if hasattr(self, 'curframe') and self.curframe:
|
||||
if self.curframe:
|
||||
self.curframe.f_globals.pop('__pdb_convenience_variables', None)
|
||||
self.curframe = None
|
||||
self.tb_lineno.clear()
|
||||
|
|
@ -1493,7 +1499,7 @@ def checkline(self, filename, lineno, module_globals=None):
|
|||
"""
|
||||
# this method should be callable before starting debugging, so default
|
||||
# to "no globals" if there is no current frame
|
||||
frame = getattr(self, 'curframe', None)
|
||||
frame = self.curframe
|
||||
if module_globals is None:
|
||||
module_globals = frame.f_globals if frame else None
|
||||
line = linecache.getline(filename, lineno, module_globals)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Initialize all Pdb's instance variables in ``__init__``, remove some hasattr/getattr
|
||||
Loading…
Add table
Add a link
Reference in a new issue