prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  UnicodeEncodeError when the defualt value is used and contains non ascii characters.
  Error occurs when the user uses the default unicode string.
  
  Code:
  
  ```
  if PY3:
      cookiecutter_dict[key] = new_val
  else:
      cookiecutter_dict[key] = new_val.decode('utf-8')
  ```
  
  Everything is okay in Python 3, but `new_val` is already unicode in 2.x.
  
  
  </issue>
  <code>
  [start of cookiecutter/prompt.py]
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 
  4 """
  5 cookiecutter.prompt
  6 ---------------------
  7 
  8 Functions for prompting the user for project info.
  9 """
  10 
  11 from __future__ import unicode_literals
  12 import sys
  13 
  14 PY3 = sys.version > '3'
  15 if PY3:
  16     iteritems = lambda d: iter(d.items())
  17 else:
  18     input = raw_input
  19     iteritems = lambda d: d.iteritems()
  20 
  21 def prompt_for_config(context):
  22     """
  23     Prompts the user to enter new config, using context as a source for the
  24     field names and sample values.
  25     """
  26     cookiecutter_dict = {}
  27 
  28     for key, val in iteritems(context['cookiecutter']):
  29         prompt = "{0} (default is \"{1}\")? ".format(key, val)
  30         new_val = input(prompt.encode('utf-8'))
  31         new_val = new_val.strip()
  32 
  33         if new_val == '':
  34             new_val = val
  35 
  36         if PY3:
  37             cookiecutter_dict[key] = new_val
  38         else:
  39             cookiecutter_dict[key] = new_val.decode('utf-8')
  40     return cookiecutter_dict
  41 
  42 
  43 def query_yes_no(question, default="yes"):
  44     """
  45     Ask a yes/no question via `raw_input()` and return their answer.
  46 
  47     :param question: A string that is presented to the user.
  48     :param default: The presumed answer if the user just hits <Enter>.
  49         It must be "yes" (the default), "no" or None (meaning
  50         an answer is required of the user).
  51 
  52     The "answer" return value is one of "yes" or "no".
  53 
  54     Adapted from
  55     http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input
  56     http://code.activestate.com/recipes/577058/
  57 
  58     """
  59     valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False}
  60     if default is None:
  61         prompt = " [y/n] "
  62     elif default == "yes":
  63         prompt = " [Y/n] "
  64     elif default == "no":
  65         prompt = " [y/N] "
  66     else:
  67         raise ValueError("invalid default answer: '%s'" % default)
  68 
  69     while True:
  70         sys.stdout.write(question + prompt)
  71         choice = input().lower()
  72 
  73         if default is not None and choice == '':
  74             return valid[default]
  75         elif choice in valid:
  76             return valid[choice]
  77         else:
  78             sys.stdout.write("Please respond with 'yes' or 'no' "
  79                              "(or 'y' or 'n').\n")
  80
  [end of cookiecutter/prompt.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/cookiecutter/prompt.py b/cookiecutter/prompt.py
  --- a/cookiecutter/prompt.py
  +++ b/cookiecutter/prompt.py
  @@ -18,6 +18,7 @@
       input = raw_input
       iteritems = lambda d: d.iteritems()
   
  +
   def prompt_for_config(context):
       """
       Prompts the user to enter new config, using context as a source for the
  @@ -27,16 +28,18 @@
   
       for key, val in iteritems(context['cookiecutter']):
           prompt = "{0} (default is \"{1}\")? ".format(key, val)
  -        new_val = input(prompt.encode('utf-8'))
  +
  +        if PY3:
  +            new_val = input(prompt.encode('utf-8'))
  +        else:
  +            new_val = input(prompt.encode('utf-8')).decode('utf-8')
  +
           new_val = new_val.strip()
   
           if new_val == '':
               new_val = val
   
  -        if PY3:
  -            cookiecutter_dict[key] = new_val
  -        else:
  -            cookiecutter_dict[key] = new_val.decode('utf-8')
  +        cookiecutter_dict[key] = new_val
       return cookiecutter_dict
  
verification_info: {"golden_diff": "diff --git a/cookiecutter/prompt.py b/cookiecutter/prompt.py\n--- a/cookiecutter/prompt.py\n+++ b/cookiecutter/prompt.py\n@@ -18,6 +18,7 @@\n     input = raw_input\n     iteritems = lambda d: d.iteritems()\n \n+\n def prompt_for_config(context):\n     \"\"\"\n     Prompts the user to enter new config, using context as a source for the\n@@ -27,16 +28,18 @@\n \n     for key, val in iteritems(context['cookiecutter']):\n         prompt = \"{0} (default is \\\"{1}\\\")? \".format(key, val)\n-        new_val = input(prompt.encode('utf-8'))\n+\n+        if PY3:\n+            new_val = input(prompt.encode('utf-8'))\n+        else:\n+            new_val = input(prompt.encode('utf-8')).decode('utf-8')\n+\n         new_val = new_val.strip()\n \n         if new_val == '':\n             new_val = val\n \n-        if PY3:\n-            cookiecutter_dict[key] = new_val\n-        else:\n-            cookiecutter_dict[key] = new_val.decode('utf-8')\n+        cookiecutter_dict[key] = new_val\n     return cookiecutter_dict\n", "issue": "UnicodeEncodeError when the defualt value is used and contains non ascii characters.\nError occurs when the user uses the default unicode string.\n\nCode:\n\n```\nif PY3:\n    cookiecutter_dict[key] = new_val\nelse:\n    cookiecutter_dict[key] = new_val.decode('utf-8')\n```\n\nEverything is okay in Python 3, but `new_val` is already unicode in 2.x.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.prompt\n---------------------\n\nFunctions for prompting the user for project info.\n\"\"\"\n\nfrom __future__ import unicode_literals\nimport sys\n\nPY3 = sys.version > '3'\nif PY3:\n    iteritems = lambda d: iter(d.items())\nelse:\n    input = raw_input\n    iteritems = lambda d: d.iteritems()\n\ndef prompt_for_config(context):\n    \"\"\"\n    Prompts the user to enter new config, using context as a source for the\n    field names and sample values.\n    \"\"\"\n    cookiecutter_dict = {}\n\n    for key, val in iteritems(context['cookiecutter']):\n        prompt = \"{0} (default is \\\"{1}\\\")? \".format(key, val)\n        new_val = input(prompt.encode('utf-8'))\n        new_val = new_val.strip()\n\n        if new_val == '':\n            new_val = val\n\n        if PY3:\n            cookiecutter_dict[key] = new_val\n        else:\n            cookiecutter_dict[key] = new_val.decode('utf-8')\n    return cookiecutter_dict\n\n\ndef query_yes_no(question, default=\"yes\"):\n    \"\"\"\n    Ask a yes/no question via `raw_input()` and return their answer.\n\n    :param question: A string that is presented to the user.\n    :param default: The presumed answer if the user just hits <Enter>.\n        It must be \"yes\" (the default), \"no\" or None (meaning\n        an answer is required of the user).\n\n    The \"answer\" return value is one of \"yes\" or \"no\".\n\n    Adapted from\n    http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input\n    http://code.activestate.com/recipes/577058/\n\n    \"\"\"\n    valid = {\"yes\": True, \"y\": True, \"ye\": True, \"no\": False, \"n\": False}\n    if default is None:\n        prompt = \" [y/n] \"\n    elif default == \"yes\":\n        prompt = \" [Y/n] \"\n    elif default == \"no\":\n        prompt = \" [y/N] \"\n    else:\n        raise ValueError(\"invalid default answer: '%s'\" % default)\n\n    while True:\n        sys.stdout.write(question + prompt)\n        choice = input().lower()\n\n        if default is not None and choice == '':\n            return valid[default]\n        elif choice in valid:\n            return valid[choice]\n        else:\n            sys.stdout.write(\"Please respond with 'yes' or 'no' \"\n                             \"(or 'y' or 'n').\\n\")\n", "path": "cookiecutter/prompt.py"}]}