prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Macro search results are mangled for non-en-US locales
  See for example https://wiki.developer.mozilla.org/en-US/search?locale=*&kumascript_macros=WebExtAllExamples&topic=none
  
  This lists all pages that call WebExtAllExamples, across all locales. One entry looks like:
  
  <img width="893" alt="Screen Shot 2019-11-21 at 4 30 25 PM" src="https://user-images.githubusercontent.com/432915/69387936-3e5d4780-0c7c-11ea-9347-5916d638d12d.png">
  
  This is the German translation of the https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples page.
  
  But the first link, "**Beispiele für Erweiterungen**", has the en-US locale in the URL, like this: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - note the translated slug but the en-US locale. If I click it, I get "Create a new page", because that page doesn't exist.
  
  After the short description, the entry is supposed to have "`${url} Score: 82.20941 translated from ${original}`, where `url` is the localized page, and `original` is the en-US version. But these are wrong too:
  
  * `url`: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - nonexistent page with en-US locale but de slug
  * `original`: https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Beispiele - the proper value for `url`
  
   I've seen some cases where the "`${url} Score: 82.20941 translated from ${original}` bit doesn't appear, and then there is no usable link to the actual page, and I have to guess what the locale is, to be able to fix the link.
  
  
  
  </issue>
  <code>
  [start of kuma/search/fields.py]
  1 from django.conf import settings
  2 from rest_framework import serializers
  3 
  4 from kuma.core.urlresolvers import reverse
  5 
  6 
  7 class SearchQueryField(serializers.ReadOnlyField):
  8     """
  9     Field that returns the search query of the current request.
  10     """
  11     def __init__(self, *args, **kwargs):
  12         kwargs['source'] = '*'
  13         super(SearchQueryField, self).__init__(*args, **kwargs)
  14 
  15     def to_representation(self, value):
  16         request = self.context.get('request')
  17         if request is None:
  18             return ''
  19         else:
  20             return request.query_params.get('q', None)
  21 
  22 
  23 class SiteURLField(serializers.ReadOnlyField):
  24     """
  25     A serializer field for creating URL for the given objects with the
  26     given ``args``/``kwargs`` and a required ``locale`` attribute.
  27     """
  28     def __init__(self, url_name, args=None, kwargs=None):
  29         self.url_name = url_name
  30         self.args = args or []
  31         self.kwargs = kwargs or []
  32         super(SiteURLField, self).__init__(source='*')
  33 
  34     def to_representation(self, value):
  35         if not value:
  36             return None
  37         args = [getattr(value, arg) for arg in self.args]
  38         kwargs = {arg: getattr(value, arg) for arg in self.kwargs}
  39         locale = getattr(value, 'locale', settings.LANGUAGE_CODE)
  40         path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)
  41         return '%s%s' % (settings.SITE_URL, path)
  42
  [end of kuma/search/fields.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/kuma/search/fields.py b/kuma/search/fields.py
  --- a/kuma/search/fields.py
  +++ b/kuma/search/fields.py
  @@ -37,5 +37,4 @@
           args = [getattr(value, arg) for arg in self.args]
           kwargs = {arg: getattr(value, arg) for arg in self.kwargs}
           locale = getattr(value, 'locale', settings.LANGUAGE_CODE)
  -        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)
  -        return '%s%s' % (settings.SITE_URL, path)
  +        return reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)
  
verification_info: {"golden_diff": "diff --git a/kuma/search/fields.py b/kuma/search/fields.py\n--- a/kuma/search/fields.py\n+++ b/kuma/search/fields.py\n@@ -37,5 +37,4 @@\n         args = [getattr(value, arg) for arg in self.args]\n         kwargs = {arg: getattr(value, arg) for arg in self.kwargs}\n         locale = getattr(value, 'locale', settings.LANGUAGE_CODE)\n-        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n-        return '%s%s' % (settings.SITE_URL, path)\n+        return reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n", "issue": "Macro search results are mangled for non-en-US locales\nSee for example https://wiki.developer.mozilla.org/en-US/search?locale=*&kumascript_macros=WebExtAllExamples&topic=none\r\n\r\nThis lists all pages that call WebExtAllExamples, across all locales. One entry looks like:\r\n\r\n<img width=\"893\" alt=\"Screen Shot 2019-11-21 at 4 30 25 PM\" src=\"https://user-images.githubusercontent.com/432915/69387936-3e5d4780-0c7c-11ea-9347-5916d638d12d.png\">\r\n\r\nThis is the German translation of the https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples page.\r\n\r\nBut the first link, \"**Beispiele f\u00fcr Erweiterungen**\", has the en-US locale in the URL, like this: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - note the translated slug but the en-US locale. If I click it, I get \"Create a new page\", because that page doesn't exist.\r\n\r\nAfter the short description, the entry is supposed to have \"`${url} Score: 82.20941 translated from ${original}`, where `url` is the localized page, and `original` is the en-US version. But these are wrong too:\r\n\r\n* `url`: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - nonexistent page with en-US locale but de slug\r\n* `original`: https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Beispiele - the proper value for `url`\r\n\r\n I've seen some cases where the \"`${url} Score: 82.20941 translated from ${original}` bit doesn't appear, and then there is no usable link to the actual page, and I have to guess what the locale is, to be able to fix the link.\r\n\r\n\n", "before_files": [{"content": "from django.conf import settings\nfrom rest_framework import serializers\n\nfrom kuma.core.urlresolvers import reverse\n\n\nclass SearchQueryField(serializers.ReadOnlyField):\n    \"\"\"\n    Field that returns the search query of the current request.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        kwargs['source'] = '*'\n        super(SearchQueryField, self).__init__(*args, **kwargs)\n\n    def to_representation(self, value):\n        request = self.context.get('request')\n        if request is None:\n            return ''\n        else:\n            return request.query_params.get('q', None)\n\n\nclass SiteURLField(serializers.ReadOnlyField):\n    \"\"\"\n    A serializer field for creating URL for the given objects with the\n    given ``args``/``kwargs`` and a required ``locale`` attribute.\n    \"\"\"\n    def __init__(self, url_name, args=None, kwargs=None):\n        self.url_name = url_name\n        self.args = args or []\n        self.kwargs = kwargs or []\n        super(SiteURLField, self).__init__(source='*')\n\n    def to_representation(self, value):\n        if not value:\n            return None\n        args = [getattr(value, arg) for arg in self.args]\n        kwargs = {arg: getattr(value, arg) for arg in self.kwargs}\n        locale = getattr(value, 'locale', settings.LANGUAGE_CODE)\n        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n        return '%s%s' % (settings.SITE_URL, path)\n", "path": "kuma/search/fields.py"}]}