We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Profiles generated with fake_data.py 500 when viewed
Introduced in a4b904f

This is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.

```
Traceback (most recent call last):
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 66, in handle_safely
    response = self.handle(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 99, in handle
    response = request.resource.respond(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py", line 57, in respond
    response = self.get_response(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py", line 100, in get_response
    response.body = render(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py", line 113, in __call__
    return self.render_content(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py", line 14, in render_content
    return self.compiled.generate(**context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py", line 129, in generate
    return execute()
  File "/home/joe/git/www.gittip.com/www/%username/index.html", line 786, in _execute
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py", line 52, in xhtml_escape
    return xml.sax.saxutils.escape(value, {'"': """})
  File "/usr/lib/python2.7/xml/sax/saxutils.py", line 39, in escape
    data = data.replace("&", "&")
AttributeError: 'NoneType' object has no attribute 'replace'
```

Profiles generated with fake_data.py 500 when viewed
Introduced in a4b904f

This is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.

```
Traceback (most recent call last):
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 66, in handle_safely
    response = self.handle(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 99, in handle
    response = request.resource.respond(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py", line 57, in respond
    response = self.get_response(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py", line 100, in get_response
    response.body = render(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py", line 113, in __call__
    return self.render_content(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py", line 14, in render_content
    return self.compiled.generate(**context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py", line 129, in generate
    return execute()
  File "/home/joe/git/www.gittip.com/www/%username/index.html", line 786, in _execute
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py", line 52, in xhtml_escape
    return xml.sax.saxutils.escape(value, {'"': """})
  File "/usr/lib/python2.7/xml/sax/saxutils.py", line 39, in escape
    data = data.replace("&", "&")
AttributeError: 'NoneType' object has no attribute 'replace'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gittip/fake_data.py`
Content:
```
1 from faker import Factory
2 from gittip import orm
3 from gittip.models.tip import Tip
4 from gittip.models.participant import Participant
5 from gittip.models.elsewhere import Elsewhere
6 from gittip import AMOUNTS
7 import string
8 import random
9 
10 faker = Factory.create()
11 
12 platforms = ['github', 'twitter']
13 
14 
15 def fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):
16     """
17     Create a random text id
18     """
19     return ''.join(random.choice(chars) for x in range(size))
20 
21 
22 def fake_balance(max_amount=100):
23     """
24     Return a random amount between 0 and max_amount
25     """
26     return random.random() * max_amount
27 
28 def fake_int_id(nmax=2 ** 31 -1):
29     """
30     Create a random int id
31     """
32     return random.randint(0, nmax)
33 
34 
35 def fake_participant(is_admin=False, anonymous=False):
36     """
37     Create a fake User
38     """
39     username = faker.firstName() + fake_text_id(3)
40     return Participant(
41         id=fake_int_id(),
42         username=username,
43         username_lower=username.lower(),
44         statement=faker.sentence(),
45         ctime=faker.dateTimeThisYear(),
46         is_admin=is_admin,
47         balance=fake_balance(),
48         anonymous=anonymous,
49         goal=fake_balance(),
50         balanced_account_uri=faker.uri(),
51         last_ach_result='',
52         is_suspicious=False,
53         last_bill_result='',  # Needed to not be suspicious
54         claimed_time=faker.dateTimeThisYear(),
55         type="individual"
56     )
57 
58 
59 def fake_tip(tipper, tippee):
60     """
61     Create a fake tip
62     """
63     return Tip(
64         id=fake_int_id(),
65         ctime=faker.dateTimeThisYear(),
66         mtime=faker.dateTimeThisMonth(),
67         tipper=tipper.username,
68         tippee=tippee.username,
69         amount=random.choice(AMOUNTS)
70     )
71 
72 
73 def fake_elsewhere(participant, platform=None):
74     """
75     Create a fake elsewhere
76     """
77     if platform is None:
78         platform = random.choice(platforms)
79 
80     return Elsewhere(
81         id=fake_int_id(),
82         platform=platform,
83         user_id=fake_text_id(),
84         is_locked=False,
85         participant=participant.username,
86         user_info=''
87     )
88 
89 
90 def populate_db(session, num_participants=100, num_tips=50):
91     """
92     Populate DB with fake data
93     """
94     #Make the participants
95     participants = []
96     for i in xrange(num_participants):
97         p = fake_participant()
98         session.add(p)
99         participants.append(p)
100 
101     #Make the "Elsewhere's"
102     for p in participants:
103         #All participants get 1 or 2 elsewheres
104         num_elsewheres = random.randint(1, 2)
105         for platform_name in platforms[:num_elsewheres]:
106             e = fake_elsewhere(p, platform_name)
107             session.add(e)
108 
109     #Make the tips
110     tips = []
111     for i in xrange(num_tips):
112         tipper, tippee = random.sample(participants, 2)
113         t = fake_tip(tipper, tippee)
114         tips.append(t)
115         session.add(t)
116     session.commit()
117 
118 
119 def main():
120     db = orm.db
121     dbsession = db.session
122     populate_db(dbsession)
123 
124 if __name__ == '__main__':
125     main()
126
```
--- 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/gittip/fake_data.py b/gittip/fake_data.py
--- a/gittip/fake_data.py
+++ b/gittip/fake_data.py
@@ -9,7 +9,7 @@
 
 faker = Factory.create()
 
-platforms = ['github', 'twitter']
+platforms = ['github', 'twitter', 'bitbucket']
 
 
 def fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):
@@ -77,13 +77,33 @@
     if platform is None:
         platform = random.choice(platforms)
 
+    info_templates = {
+        "github": {
+            "name": participant.username,
+            "html_url": "https://github.com/" + participant.username,
+            "type": "User",
+            "login": participant.username
+        },
+        "twitter": {
+            "name": participant.username,
+            "html_url": "https://twitter.com/" + participant.username,
+            "screen_name": participant.username
+        },
+        "bitbucket": {
+            "display_name": participant.username,
+            "username": participant.username,
+            "is_team": "False",
+            "html_url": "https://bitbucket.org/" + participant.username,
+        }
+    }
+
     return Elsewhere(
         id=fake_int_id(),
         platform=platform,
         user_id=fake_text_id(),
         is_locked=False,
         participant=participant.username,
-        user_info=''
+        user_info=info_templates[platform]
     )
 
 
@@ -100,8 +120,8 @@
 
     #Make the "Elsewhere's"
     for p in participants:
-        #All participants get 1 or 2 elsewheres
-        num_elsewheres = random.randint(1, 2)
+        #All participants get between 1 and 3 elsewheres
+        num_elsewheres = random.randint(1, 3)
         for platform_name in platforms[:num_elsewheres]:
             e = fake_elsewhere(p, platform_name)
             session.add(e)

{"golden_diff": "diff --git a/gittip/fake_data.py b/gittip/fake_data.py\n--- a/gittip/fake_data.py\n+++ b/gittip/fake_data.py\n@@ -9,7 +9,7 @@\n \n faker = Factory.create()\n \n-platforms = ['github', 'twitter']\n+platforms = ['github', 'twitter', 'bitbucket']\n \n \n def fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):\n@@ -77,13 +77,33 @@\n     if platform is None:\n         platform = random.choice(platforms)\n \n+    info_templates = {\n+        \"github\": {\n+            \"name\": participant.username,\n+            \"html_url\": \"https://github.com/\" + participant.username,\n+            \"type\": \"User\",\n+            \"login\": participant.username\n+        },\n+        \"twitter\": {\n+            \"name\": participant.username,\n+            \"html_url\": \"https://twitter.com/\" + participant.username,\n+            \"screen_name\": participant.username\n+        },\n+        \"bitbucket\": {\n+            \"display_name\": participant.username,\n+            \"username\": participant.username,\n+            \"is_team\": \"False\",\n+            \"html_url\": \"https://bitbucket.org/\" + participant.username,\n+        }\n+    }\n+\n     return Elsewhere(\n         id=fake_int_id(),\n         platform=platform,\n         user_id=fake_text_id(),\n         is_locked=False,\n         participant=participant.username,\n-        user_info=''\n+        user_info=info_templates[platform]\n     )\n \n \n@@ -100,8 +120,8 @@\n \n     #Make the \"Elsewhere's\"\n     for p in participants:\n-        #All participants get 1 or 2 elsewheres\n-        num_elsewheres = random.randint(1, 2)\n+        #All participants get between 1 and 3 elsewheres\n+        num_elsewheres = random.randint(1, 3)\n         for platform_name in platforms[:num_elsewheres]:\n             e = fake_elsewhere(p, platform_name)\n             session.add(e)\n", "issue": "Profiles generated with fake_data.py 500 when viewed\nIntroduced in a4b904f\n\nThis is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.\n\n```\nTraceback (most recent call last):\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py\", line 66, in handle_safely\n    response = self.handle(request)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py\", line 99, in handle\n    response = request.resource.respond(request)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py\", line 57, in respond\n    response = self.get_response(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py\", line 100, in get_response\n    response.body = render(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py\", line 113, in __call__\n    return self.render_content(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py\", line 14, in render_content\n    return self.compiled.generate(**context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py\", line 129, in generate\n    return execute()\n  File \"/home/joe/git/www.gittip.com/www/%username/index.html\", line 786, in _execute\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py\", line 52, in xhtml_escape\n    return xml.sax.saxutils.escape(value, {'\"': \"\"\"})\n  File \"/usr/lib/python2.7/xml/sax/saxutils.py\", line 39, in escape\n    data = data.replace(\"&\", \"&\")\nAttributeError: 'NoneType' object has no attribute 'replace'\n```\n\nProfiles generated with fake_data.py 500 when viewed\nIntroduced in a4b904f\n\nThis is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.\n\n```\nTraceback (most recent call last):\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py\", line 66, in handle_safely\n    response = self.handle(request)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py\", line 99, in handle\n    response = request.resource.respond(request)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py\", line 57, in respond\n    response = self.get_response(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py\", line 100, in get_response\n    response.body = render(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py\", line 113, in __call__\n    return self.render_content(context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py\", line 14, in render_content\n    return self.compiled.generate(**context)\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py\", line 129, in generate\n    return execute()\n  File \"/home/joe/git/www.gittip.com/www/%username/index.html\", line 786, in _execute\n  File \"/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py\", line 52, in xhtml_escape\n    return xml.sax.saxutils.escape(value, {'\"': \"\"\"})\n  File \"/usr/lib/python2.7/xml/sax/saxutils.py\", line 39, in escape\n    data = data.replace(\"&\", \"&\")\nAttributeError: 'NoneType' object has no attribute 'replace'\n```\n\n", "before_files": [{"content": "from faker import Factory\nfrom gittip import orm\nfrom gittip.models.tip import Tip\nfrom gittip.models.participant import Participant\nfrom gittip.models.elsewhere import Elsewhere\nfrom gittip import AMOUNTS\nimport string\nimport random\n\nfaker = Factory.create()\n\nplatforms = ['github', 'twitter']\n\n\ndef fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):\n    \"\"\"\n    Create a random text id\n    \"\"\"\n    return ''.join(random.choice(chars) for x in range(size))\n\n\ndef fake_balance(max_amount=100):\n    \"\"\"\n    Return a random amount between 0 and max_amount\n    \"\"\"\n    return random.random() * max_amount\n\ndef fake_int_id(nmax=2 ** 31 -1):\n    \"\"\"\n    Create a random int id\n    \"\"\"\n    return random.randint(0, nmax)\n\n\ndef fake_participant(is_admin=False, anonymous=False):\n    \"\"\"\n    Create a fake User\n    \"\"\"\n    username = faker.firstName() + fake_text_id(3)\n    return Participant(\n        id=fake_int_id(),\n        username=username,\n        username_lower=username.lower(),\n        statement=faker.sentence(),\n        ctime=faker.dateTimeThisYear(),\n        is_admin=is_admin,\n        balance=fake_balance(),\n        anonymous=anonymous,\n        goal=fake_balance(),\n        balanced_account_uri=faker.uri(),\n        last_ach_result='',\n        is_suspicious=False,\n        last_bill_result='',  # Needed to not be suspicious\n        claimed_time=faker.dateTimeThisYear(),\n        type=\"individual\"\n    )\n\n\ndef fake_tip(tipper, tippee):\n    \"\"\"\n    Create a fake tip\n    \"\"\"\n    return Tip(\n        id=fake_int_id(),\n        ctime=faker.dateTimeThisYear(),\n        mtime=faker.dateTimeThisMonth(),\n        tipper=tipper.username,\n        tippee=tippee.username,\n        amount=random.choice(AMOUNTS)\n    )\n\n\ndef fake_elsewhere(participant, platform=None):\n    \"\"\"\n    Create a fake elsewhere\n    \"\"\"\n    if platform is None:\n        platform = random.choice(platforms)\n\n    return Elsewhere(\n        id=fake_int_id(),\n        platform=platform,\n        user_id=fake_text_id(),\n        is_locked=False,\n        participant=participant.username,\n        user_info=''\n    )\n\n\ndef populate_db(session, num_participants=100, num_tips=50):\n    \"\"\"\n    Populate DB with fake data\n    \"\"\"\n    #Make the participants\n    participants = []\n    for i in xrange(num_participants):\n        p = fake_participant()\n        session.add(p)\n        participants.append(p)\n\n    #Make the \"Elsewhere's\"\n    for p in participants:\n        #All participants get 1 or 2 elsewheres\n        num_elsewheres = random.randint(1, 2)\n        for platform_name in platforms[:num_elsewheres]:\n            e = fake_elsewhere(p, platform_name)\n            session.add(e)\n\n    #Make the tips\n    tips = []\n    for i in xrange(num_tips):\n        tipper, tippee = random.sample(participants, 2)\n        t = fake_tip(tipper, tippee)\n        tips.append(t)\n        session.add(t)\n    session.commit()\n\n\ndef main():\n    db = orm.db\n    dbsession = db.session\n    populate_db(dbsession)\n\nif __name__ == '__main__':\n    main()\n", "path": "gittip/fake_data.py"}], "after_files": [{"content": "from faker import Factory\nfrom gittip import orm\nfrom gittip.models.tip import Tip\nfrom gittip.models.participant import Participant\nfrom gittip.models.elsewhere import Elsewhere\nfrom gittip import AMOUNTS\nimport string\nimport random\n\nfaker = Factory.create()\n\nplatforms = ['github', 'twitter', 'bitbucket']\n\n\ndef fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):\n    \"\"\"\n    Create a random text id\n    \"\"\"\n    return ''.join(random.choice(chars) for x in range(size))\n\n\ndef fake_balance(max_amount=100):\n    \"\"\"\n    Return a random amount between 0 and max_amount\n    \"\"\"\n    return random.random() * max_amount\n\ndef fake_int_id(nmax=2 ** 31 -1):\n    \"\"\"\n    Create a random int id\n    \"\"\"\n    return random.randint(0, nmax)\n\n\ndef fake_participant(is_admin=False, anonymous=False):\n    \"\"\"\n    Create a fake User\n    \"\"\"\n    username = faker.firstName() + fake_text_id(3)\n    return Participant(\n        id=fake_int_id(),\n        username=username,\n        username_lower=username.lower(),\n        statement=faker.sentence(),\n        ctime=faker.dateTimeThisYear(),\n        is_admin=is_admin,\n        balance=fake_balance(),\n        anonymous=anonymous,\n        goal=fake_balance(),\n        balanced_account_uri=faker.uri(),\n        last_ach_result='',\n        is_suspicious=False,\n        last_bill_result='',  # Needed to not be suspicious\n        claimed_time=faker.dateTimeThisYear(),\n        type=\"individual\"\n    )\n\n\ndef fake_tip(tipper, tippee):\n    \"\"\"\n    Create a fake tip\n    \"\"\"\n    return Tip(\n        id=fake_int_id(),\n        ctime=faker.dateTimeThisYear(),\n        mtime=faker.dateTimeThisMonth(),\n        tipper=tipper.username,\n        tippee=tippee.username,\n        amount=random.choice(AMOUNTS)\n    )\n\n\ndef fake_elsewhere(participant, platform=None):\n    \"\"\"\n    Create a fake elsewhere\n    \"\"\"\n    if platform is None:\n        platform = random.choice(platforms)\n\n    info_templates = {\n        \"github\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://github.com/\" + participant.username,\n            \"type\": \"User\",\n            \"login\": participant.username\n        },\n        \"twitter\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://twitter.com/\" + participant.username,\n            \"screen_name\": participant.username\n        },\n        \"bitbucket\": {\n            \"display_name\": participant.username,\n            \"username\": participant.username,\n            \"is_team\": \"False\",\n            \"html_url\": \"https://bitbucket.org/\" + participant.username,\n        }\n    }\n\n    return Elsewhere(\n        id=fake_int_id(),\n        platform=platform,\n        user_id=fake_text_id(),\n        is_locked=False,\n        participant=participant.username,\n        user_info=info_templates[platform]\n    )\n\n\ndef populate_db(session, num_participants=100, num_tips=50):\n    \"\"\"\n    Populate DB with fake data\n    \"\"\"\n    #Make the participants\n    participants = []\n    for i in xrange(num_participants):\n        p = fake_participant()\n        session.add(p)\n        participants.append(p)\n\n    #Make the \"Elsewhere's\"\n    for p in participants:\n        #All participants get between 1 and 3 elsewheres\n        num_elsewheres = random.randint(1, 3)\n        for platform_name in platforms[:num_elsewheres]:\n            e = fake_elsewhere(p, platform_name)\n            session.add(e)\n\n    #Make the tips\n    tips = []\n    for i in xrange(num_tips):\n        tipper, tippee = random.sample(participants, 2)\n        t = fake_tip(tipper, tippee)\n        tips.append(t)\n        session.add(t)\n    session.commit()\n\n\ndef main():\n    db = orm.db\n    dbsession = db.session\n    populate_db(dbsession)\n\nif __name__ == '__main__':\n    main()\n", "path": "gittip/fake_data.py"}]}