prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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.
  
  </issue>
  <code>
  [start of sentry_sdk/integrations/django/signals_handlers.py]
  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 of sentry_sdk/integrations/django/signals_handlers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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
  
verification_info: {"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"}]}