Repository: PyCQA/flake8-bugbear

Issue:
Error in latest version of flake8-bugbear 24.1.15
Getting error with latest version of flake8-bugbear

```
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 83, in _mp_run
    ).run_checks()
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 526, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 428, in run_ast_checks
    for line_number, offset, text, _ in runner:
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 80, in run
    visitor.visit(self.tree)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 419, in visit
    super().visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 510, in visit_Module
    self.generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 426, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 419, in visit
    super().visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 575, in visit_ClassDef
    self.generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 426, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 419, in visit
    super().visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 569, in visit_FunctionDef
    self.generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 426, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 419, in visit
    super().visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 580, in visit_Try
    self.generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 426, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 419, in visit
    super().visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 464, in visit_ExceptHandler
    and not ExceptBaseExceptionVisitor(node).re_raised()
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 337, in re_raised
    self.visit(self.root)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 352, in visit_ExceptHandler
    return super().generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 426, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/ast.py", line 418, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/bugbear.py", line 344, in visit_Raise
    if node.exc is None or node.exc.id == self.root.name:
AttributeError: 'Call' object has no attribute 'id'
"""
```

Discussion:

Patch:
diff --git a/README.rst b/README.rst
index 45acc66..524472f 100644
--- a/README.rst
+++ b/README.rst
@@ -349,6 +349,12 @@ MIT
 Change Log
 ----------
 
+Unreleased
+~~~~~~~~~~
+
+* B036: Fix crash on `raise` statements raising something other than
+  a bare name (#450)
+
 24.1.15
 ~~~~~~~
 
diff --git a/bugbear.py b/bugbear.py
index 988e995..8f47666 100644
--- a/bugbear.py
+++ b/bugbear.py
@@ -341,7 +341,9 @@ class ExceptBaseExceptionVisitor(ast.NodeVisitor):
         """If we find a corresponding `raise` or `raise e` where e was from
         `except BaseException as e:` then we mark re_raised as True and can
         stop scanning."""
-        if node.exc is None or node.exc.id == self.root.name:
+        if node.exc is None or (
+            isinstance(node.exc, ast.Name) and node.exc.id == self.root.name
+        ):
             self._re_raised = True
             return
         return super().generic_visit(node)


Test patch:
diff --git a/tests/b036.py b/tests/b036.py
index 67f404d..933ee8f 100644
--- a/tests/b036.py
+++ b/tests/b036.py
@@ -52,3 +52,8 @@ except BaseException:
         pass
     except ValueError:
         raise  # bad - raising within a nested try/except, but not within the main one
+
+try:
+    pass
+except BaseException:
+    raise a.b from None  # bad (regression test for #449)
diff --git a/tests/test_bugbear.py b/tests/test_bugbear.py
index 88e523c..0bac96b 100644
--- a/tests/test_bugbear.py
+++ b/tests/test_bugbear.py
@@ -618,6 +618,7 @@ class BugbearTestCase(unittest.TestCase):
             B036(20, 0),
             B036(33, 0),
             B036(50, 0),
+            B036(58, 0),
         )
         self.assertEqual(errors, expected)