prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Unicode content in rich text causes error
  Steps to reproduce:
  1. Using the wagtail interface, create a new instance of a page derived model which has a rich text field
  2. In the rich text field, include unicode characters such as: `©`  or `’`
  3. Publish the page
     
     The page will be published fine, and probably rendered normally through a template.
  4. Return to the wagtail admin, and edit the newly created page
     
     The rich text field is not rendered in the editing page. Inspecting the html shows that wagtail is attempting to render the field, its heading is there. But the field is not rendered.
     
     If you attempt to publish this new page, the form will submit a page with no content in the rich text field.
  
  
  </issue>
  <code>
  [start of wagtail/utils/widgets.py]
  1 from django.forms.widgets import Widget
  2 from django.utils.safestring import mark_safe
  3 
  4 
  5 class WidgetWithScript(Widget):
  6     def render(self, name, value, attrs=None):
  7         widget = super(WidgetWithScript, self).render(name, value, attrs)
  8 
  9         final_attrs = self.build_attrs(attrs, name=name)
  10         id_ = final_attrs.get('id', None)
  11         if 'id_' is None:
  12             return widget
  13 
  14         js = self.render_js_init(id_, name, value)
  15         out = '{0}<script>{1}</script>'.format(widget, js)
  16         return mark_safe(out)
  17 
  18     def render_js_init(self, id_, name, value):
  19         return ''
  20
  [end of wagtail/utils/widgets.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/wagtail/utils/widgets.py b/wagtail/utils/widgets.py
  --- a/wagtail/utils/widgets.py
  +++ b/wagtail/utils/widgets.py
  @@ -1,3 +1,5 @@
  +from __future__ import absolute_import, unicode_literals
  +
   from django.forms.widgets import Widget
   from django.utils.safestring import mark_safe
   
  @@ -8,7 +10,7 @@
   
           final_attrs = self.build_attrs(attrs, name=name)
           id_ = final_attrs.get('id', None)
  -        if 'id_' is None:
  +        if id_ is None:
               return widget
   
           js = self.render_js_init(id_, name, value)
  
verification_info: {"golden_diff": "diff --git a/wagtail/utils/widgets.py b/wagtail/utils/widgets.py\n--- a/wagtail/utils/widgets.py\n+++ b/wagtail/utils/widgets.py\n@@ -1,3 +1,5 @@\n+from __future__ import absolute_import, unicode_literals\n+\n from django.forms.widgets import Widget\n from django.utils.safestring import mark_safe\n \n@@ -8,7 +10,7 @@\n \n         final_attrs = self.build_attrs(attrs, name=name)\n         id_ = final_attrs.get('id', None)\n-        if 'id_' is None:\n+        if id_ is None:\n             return widget\n \n         js = self.render_js_init(id_, name, value)\n", "issue": "Unicode content in rich text causes error\nSteps to reproduce:\n1. Using the wagtail interface, create a new instance of a page derived model which has a rich text field\n2. In the rich text field, include unicode characters such as: `\u00a9`  or `\u2019`\n3. Publish the page\n   \n   The page will be published fine, and probably rendered normally through a template.\n4. Return to the wagtail admin, and edit the newly created page\n   \n   The rich text field is not rendered in the editing page. Inspecting the html shows that wagtail is attempting to render the field, its heading is there. But the field is not rendered.\n   \n   If you attempt to publish this new page, the form will submit a page with no content in the rich text field.\n\n", "before_files": [{"content": "from django.forms.widgets import Widget\nfrom django.utils.safestring import mark_safe\n\n\nclass WidgetWithScript(Widget):\n    def render(self, name, value, attrs=None):\n        widget = super(WidgetWithScript, self).render(name, value, attrs)\n\n        final_attrs = self.build_attrs(attrs, name=name)\n        id_ = final_attrs.get('id', None)\n        if 'id_' is None:\n            return widget\n\n        js = self.render_js_init(id_, name, value)\n        out = '{0}<script>{1}</script>'.format(widget, js)\n        return mark_safe(out)\n\n    def render_js_init(self, id_, name, value):\n        return ''\n", "path": "wagtail/utils/widgets.py"}]}