We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Django Signals integration breaks on partial objects for python <3.10
### How do you use Sentry?

Self-hosted/on-premise

### Version

1.9.9

### Steps to Reproduce

1. Use python older than 3.10.
2. Register a partial function as a signal handler.

### Expected Result

Signal is traced correctly.

### Actual Result

Exception is raised from `_get_receiver_name` function as `partial` objects don't have `__module__` before python 3.10 (and even there it's undocumented from what I can see).

It fails in our tests where we don't even register any signals so either Django itself or some kind of integration (Sentry?) registers such signals by default.

The whole signals integration is missing a `capture_internal_exceptions` context too I believe.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sentry_sdk/integrations/django/signals_handlers.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import
3 
4 from django.dispatch import Signal
5 
6 from sentry_sdk import Hub
7 from sentry_sdk._types import MYPY
8 
9 
10 if MYPY:
11     from typing import Any
12     from typing import Callable
13     from typing import List
14 
15 
16 def patch_signals():
17     # type: () -> None
18     """Patch django signal receivers to create a span"""
19 
20     old_live_receivers = Signal._live_receivers
21 
22     def _get_receiver_name(receiver):
23         # type: (Callable[..., Any]) -> str
24         name = receiver.__module__ + "."
25         if hasattr(receiver, "__name__"):
26             return name + receiver.__name__
27         return name + str(receiver)
28 
29     def _sentry_live_receivers(self, sender):
30         # type: (Signal, Any) -> List[Callable[..., Any]]
31         hub = Hub.current
32         receivers = old_live_receivers(self, sender)
33 
34         def sentry_receiver_wrapper(receiver):
35             # type: (Callable[..., Any]) -> Callable[..., Any]
36             def wrapper(*args, **kwargs):
37                 # type: (Any, Any) -> Any
38                 with hub.start_span(
39                     op="django.signals",
40                     description=_get_receiver_name(receiver),
41                 ) as span:
42                     span.set_data("signal", _get_receiver_name(receiver))
43                     return receiver(*args, **kwargs)
44 
45             return wrapper
46 
47         for idx, receiver in enumerate(receivers):
48             receivers[idx] = sentry_receiver_wrapper(receiver)
49 
50         return receivers
51 
52     Signal._live_receivers = _sentry_live_receivers
53
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sentry_sdk/integrations/django/signals_handlers.py b/sentry_sdk/integrations/django/signals_handlers.py
--- a/sentry_sdk/integrations/django/signals_handlers.py
+++ b/sentry_sdk/integrations/django/signals_handlers.py
@@ -13,19 +13,32 @@
     from typing import List
 
 
+def _get_receiver_name(receiver):
+    # type: (Callable[..., Any]) -> str
+    name = ""
+
+    if hasattr(receiver, "__qualname__"):
+        name += receiver.__qualname__
+    elif hasattr(receiver, "__name__"):  # Python 2.7 has no __qualname__
+        name += receiver.__name__
+
+    if (
+        name == ""
+    ):  # certain functions (like partials) dont have a name so return the string representation
+        return str(receiver)
+
+    if hasattr(receiver, "__module__"):  # prepend with module, if there is one
+        name = receiver.__module__ + "." + name
+
+    return name
+
+
 def patch_signals():
     # type: () -> None
     """Patch django signal receivers to create a span"""
 
     old_live_receivers = Signal._live_receivers
 
-    def _get_receiver_name(receiver):
-        # type: (Callable[..., Any]) -> str
-        name = receiver.__module__ + "."
-        if hasattr(receiver, "__name__"):
-            return name + receiver.__name__
-        return name + str(receiver)
-
     def _sentry_live_receivers(self, sender):
         # type: (Signal, Any) -> List[Callable[..., Any]]
         hub = Hub.current
@@ -35,11 +48,12 @@
             # type: (Callable[..., Any]) -> Callable[..., Any]
             def wrapper(*args, **kwargs):
                 # type: (Any, Any) -> Any
+                signal_name = _get_receiver_name(receiver)
                 with hub.start_span(
                     op="django.signals",
-                    description=_get_receiver_name(receiver),
+                    description=signal_name,
                 ) as span:
-                    span.set_data("signal", _get_receiver_name(receiver))
+                    span.set_data("signal", signal_name)
                     return receiver(*args, **kwargs)
 
             return wrapper

{"golden_diff": "diff --git a/sentry_sdk/integrations/django/signals_handlers.py b/sentry_sdk/integrations/django/signals_handlers.py\n--- a/sentry_sdk/integrations/django/signals_handlers.py\n+++ b/sentry_sdk/integrations/django/signals_handlers.py\n@@ -13,19 +13,32 @@\n     from typing import List\n \n \n+def _get_receiver_name(receiver):\n+    # type: (Callable[..., Any]) -> str\n+    name = \"\"\n+\n+    if hasattr(receiver, \"__qualname__\"):\n+        name += receiver.__qualname__\n+    elif hasattr(receiver, \"__name__\"):  # Python 2.7 has no __qualname__\n+        name += receiver.__name__\n+\n+    if (\n+        name == \"\"\n+    ):  # certain functions (like partials) dont have a name so return the string representation\n+        return str(receiver)\n+\n+    if hasattr(receiver, \"__module__\"):  # prepend with module, if there is one\n+        name = receiver.__module__ + \".\" + name\n+\n+    return name\n+\n+\n def patch_signals():\n     # type: () -> None\n     \"\"\"Patch django signal receivers to create a span\"\"\"\n \n     old_live_receivers = Signal._live_receivers\n \n-    def _get_receiver_name(receiver):\n-        # type: (Callable[..., Any]) -> str\n-        name = receiver.__module__ + \".\"\n-        if hasattr(receiver, \"__name__\"):\n-            return name + receiver.__name__\n-        return name + str(receiver)\n-\n     def _sentry_live_receivers(self, sender):\n         # type: (Signal, Any) -> List[Callable[..., Any]]\n         hub = Hub.current\n@@ -35,11 +48,12 @@\n             # type: (Callable[..., Any]) -> Callable[..., Any]\n             def wrapper(*args, **kwargs):\n                 # type: (Any, Any) -> Any\n+                signal_name = _get_receiver_name(receiver)\n                 with hub.start_span(\n                     op=\"django.signals\",\n-                    description=_get_receiver_name(receiver),\n+                    description=signal_name,\n                 ) as span:\n-                    span.set_data(\"signal\", _get_receiver_name(receiver))\n+                    span.set_data(\"signal\", signal_name)\n                     return receiver(*args, **kwargs)\n \n             return wrapper\n", "issue": "Django Signals integration breaks on partial objects for python <3.10\n### How do you use Sentry?\n\nSelf-hosted/on-premise\n\n### Version\n\n1.9.9\n\n### Steps to Reproduce\n\n1. Use python older than 3.10.\r\n2. Register a partial function as a signal handler.\n\n### Expected Result\n\nSignal is traced correctly.\n\n### Actual Result\n\nException is raised from `_get_receiver_name` function as `partial` objects don't have `__module__` before python 3.10 (and even there it's undocumented from what I can see).\r\n\r\nIt fails in our tests where we don't even register any signals so either Django itself or some kind of integration (Sentry?) registers such signals by default.\r\n\r\nThe whole signals integration is missing a `capture_internal_exceptions` context too I believe.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\n\nfrom django.dispatch import Signal\n\nfrom sentry_sdk import Hub\nfrom sentry_sdk._types import MYPY\n\n\nif MYPY:\n    from typing import Any\n    from typing import Callable\n    from typing import List\n\n\ndef patch_signals():\n    # type: () -> None\n    \"\"\"Patch django signal receivers to create a span\"\"\"\n\n    old_live_receivers = Signal._live_receivers\n\n    def _get_receiver_name(receiver):\n        # type: (Callable[..., Any]) -> str\n        name = receiver.__module__ + \".\"\n        if hasattr(receiver, \"__name__\"):\n            return name + receiver.__name__\n        return name + str(receiver)\n\n    def _sentry_live_receivers(self, sender):\n        # type: (Signal, Any) -> List[Callable[..., Any]]\n        hub = Hub.current\n        receivers = old_live_receivers(self, sender)\n\n        def sentry_receiver_wrapper(receiver):\n            # type: (Callable[..., Any]) -> Callable[..., Any]\n            def wrapper(*args, **kwargs):\n                # type: (Any, Any) -> Any\n                with hub.start_span(\n                    op=\"django.signals\",\n                    description=_get_receiver_name(receiver),\n                ) as span:\n                    span.set_data(\"signal\", _get_receiver_name(receiver))\n                    return receiver(*args, **kwargs)\n\n            return wrapper\n\n        for idx, receiver in enumerate(receivers):\n            receivers[idx] = sentry_receiver_wrapper(receiver)\n\n        return receivers\n\n    Signal._live_receivers = _sentry_live_receivers\n", "path": "sentry_sdk/integrations/django/signals_handlers.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\n\nfrom django.dispatch import Signal\n\nfrom sentry_sdk import Hub\nfrom sentry_sdk._types import MYPY\n\n\nif MYPY:\n    from typing import Any\n    from typing import Callable\n    from typing import List\n\n\ndef _get_receiver_name(receiver):\n    # type: (Callable[..., Any]) -> str\n    name = \"\"\n\n    if hasattr(receiver, \"__qualname__\"):\n        name += receiver.__qualname__\n    elif hasattr(receiver, \"__name__\"):  # Python 2.7 has no __qualname__\n        name += receiver.__name__\n\n    if (\n        name == \"\"\n    ):  # certain functions (like partials) dont have a name so return the string representation\n        return str(receiver)\n\n    if hasattr(receiver, \"__module__\"):  # prepend with module, if there is one\n        name = receiver.__module__ + \".\" + name\n\n    return name\n\n\ndef patch_signals():\n    # type: () -> None\n    \"\"\"Patch django signal receivers to create a span\"\"\"\n\n    old_live_receivers = Signal._live_receivers\n\n    def _sentry_live_receivers(self, sender):\n        # type: (Signal, Any) -> List[Callable[..., Any]]\n        hub = Hub.current\n        receivers = old_live_receivers(self, sender)\n\n        def sentry_receiver_wrapper(receiver):\n            # type: (Callable[..., Any]) -> Callable[..., Any]\n            def wrapper(*args, **kwargs):\n                # type: (Any, Any) -> Any\n                signal_name = _get_receiver_name(receiver)\n                with hub.start_span(\n                    op=\"django.signals\",\n                    description=signal_name,\n                ) as span:\n                    span.set_data(\"signal\", signal_name)\n                    return receiver(*args, **kwargs)\n\n            return wrapper\n\n        for idx, receiver in enumerate(receivers):\n            receivers[idx] = sentry_receiver_wrapper(receiver)\n\n        return receivers\n\n    Signal._live_receivers = _sentry_live_receivers\n", "path": "sentry_sdk/integrations/django/signals_handlers.py"}]}