From 86900a49000c4a96ad1dc34e49d8af4245b08843 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 12 Mar 2019 20:57:09 -0700 Subject: [PATCH] Fix stepping into a frame without a __name__ (GH-12064) --- Lib/bdb.py | 2 ++ Lib/test/test_bdb.py | 7 +++++++ .../next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst diff --git a/Lib/bdb.py b/Lib/bdb.py index 25c6260c47..ec0f92c06a 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -190,6 +190,8 @@ class Bdb: def is_skipped_module(self, module_name): "Return True if module_name matches any skip pattern." + if module_name is None: # some modules do not have names + return False for pattern in self.skip: if fnmatch.fnmatch(module_name, pattern): return True diff --git a/Lib/test/test_bdb.py b/Lib/test/test_bdb.py index 751dd9f695..6e82cce1f4 100644 --- a/Lib/test/test_bdb.py +++ b/Lib/test/test_bdb.py @@ -730,6 +730,13 @@ class StateTestCase(BaseTestCase): with TracerRun(self, skip=skip) as tracer: tracer.runcall(tfunc_import) + def test_skip_with_no_name_module(self): + # some frames have `globals` with no `__name__` + # for instance the second frame in this traceback + # exec(compile('raise ValueError()', '', 'exec'), {}) + bdb = Bdb(skip=['anything*']) + self.assertIs(bdb.is_skipped_module(None), False) + def test_down(self): # Check that set_down() raises BdbError at the newest frame. self.expect_set = [ diff --git a/Misc/NEWS.d/next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst b/Misc/NEWS.d/next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst new file mode 100644 index 0000000000..3bab152871 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst @@ -0,0 +1,2 @@ +Fix ``pdb`` with ``skip=...`` when stepping into a frame without a +``__name__`` global. Patch by Anthony Sottile. -- 2.49.0