Skip to content

Commit 86900a4

Browse files
asottilelisroach
authored andcommitted
Fix stepping into a frame without a __name__ (GH-12064)
1 parent 839b925 commit 86900a4

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Lib/bdb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def dispatch_exception(self, frame, arg):
190190

191191
def is_skipped_module(self, module_name):
192192
"Return True if module_name matches any skip pattern."
193+
if module_name is None: # some modules do not have names
194+
return False
193195
for pattern in self.skip:
194196
if fnmatch.fnmatch(module_name, pattern):
195197
return True

Lib/test/test_bdb.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,13 @@ def main():
730730
with TracerRun(self, skip=skip) as tracer:
731731
tracer.runcall(tfunc_import)
732732

733+
def test_skip_with_no_name_module(self):
734+
# some frames have `globals` with no `__name__`
735+
# for instance the second frame in this traceback
736+
# exec(compile('raise ValueError()', '', 'exec'), {})
737+
bdb = Bdb(skip=['anything*'])
738+
self.assertIs(bdb.is_skipped_module(None), False)
739+
733740
def test_down(self):
734741
# Check that set_down() raises BdbError at the newest frame.
735742
self.expect_set = [
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix ``pdb`` with ``skip=...`` when stepping into a frame without a
2+
``__name__`` global. Patch by Anthony Sottile.

0 commit comments

Comments
 (0)