]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix stepping into a frame without a __name__ (GH-12064)
authorAnthony Sottile <asottile@umich.edu>
Wed, 13 Mar 2019 03:57:09 +0000 (20:57 -0700)
committerLisa Roach <lisaroach14@gmail.com>
Wed, 13 Mar 2019 03:57:09 +0000 (20:57 -0700)
Lib/bdb.py
Lib/test/test_bdb.py
Misc/NEWS.d/next/Library/2019-02-26-22-41-38.bpo-36130._BnZOo.rst [new file with mode: 0644]

index 25c6260c47c7e158efa4813568a0f0802df813af..ec0f92c06a787c8854e52d8f4e87cc488bcaa634 100644 (file)
@@ -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
index 751dd9f69597574eb40641d6bb2fb33d80b4c652..6e82cce1f411b7b613c09b4ba1b936df8de009fe 100644 (file)
@@ -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 (file)
index 0000000..3bab152
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``pdb`` with ``skip=...`` when stepping into a frame without a
+``__name__`` global.  Patch by Anthony Sottile.