Skip to content

Commit 03bad22

Browse files
committed
fix: breakpoint in pdb can cause crash
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 919c7e8 commit 03bad22

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/pdb.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,9 @@ def _read_code(self, line):
926926

927927
def default(self, line):
928928
if line[:1] == '!': line = line[1:].strip()
929+
if not self.curframe:
930+
self.error("No current frame.")
931+
return
929932
locals = self.curframe.f_locals
930933
globals = self.curframe.f_globals
931934
try:
@@ -2131,6 +2134,9 @@ def do_list(self, arg):
21312134
first = self.lineno + 1
21322135
if last is None:
21332136
last = first + 10
2137+
if not self.curframe:
2138+
self.error('No current frame.')
2139+
return
21342140
filename = self.curframe.f_code.co_filename
21352141
breaklist = self.get_file_breaks(filename)
21362142
try:
@@ -2153,6 +2159,9 @@ def do_longlist(self, arg):
21532159
if arg:
21542160
self._print_invalid_arg(arg)
21552161
return
2162+
if not self.curframe:
2163+
self.error('No current frame.')
2164+
return
21562165
filename = self.curframe.f_code.co_filename
21572166
breaklist = self.get_file_breaks(filename)
21582167
try:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix: breakpoint() in pdb can cause crash.

0 commit comments

Comments
 (0)