We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cookiecutter/prompt.py`
Content:
```
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 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/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

{"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"}], "after_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\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\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        cookiecutter_dict[key] = new_val\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"}]}