We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
init fails on osx at the backend selection step
I followed the instructions given [here](https://kinto.readthedocs.io/en/stable/tutorials/install.html#from-sources), but when asked:

```
$ Select the backend you would like to use: (1 - postgresql, 2 - redis, default - memory)
```

entering `1` and `2` leads to the following error:

```
Traceback (most recent call last):
  File ".venv/bin/kinto", line 11, in <module>
    load_entry_point('kinto', 'console_scripts', 'kinto')()
  File "/work/git/kinto/kinto/__main__.py", line 108, in main
    answer = input(prompt).strip()
AttributeError: 'int' object has no attribute 'strip'
```

and entering nothing + enter will lead to the following error.

```
Traceback (most recent call last):
  File ".venv/bin/kinto", line 11, in <module>
    load_entry_point('kinto', 'console_scripts', 'kinto')()
  File "/work/git/kinto/kinto/__main__.py", line 108, in main
    answer = input(prompt).strip()
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing
```

It appears that the code expects a `string` but getting a number and null, therefore failing on the `.strip()` call [here](https://github.com/Kinto/kinto/blob/master/kinto/__main__.py#L108).

---

Entering `""`, `"1"` and `"2"` works. I'm assuming that's not the way it's designed to be? 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kinto/__main__.py`
Content:
```
1 from __future__ import print_function
2 import argparse
3 import os
4 import sys
5 import logging
6 import logging.config
7 
8 from kinto.core import scripts
9 from pyramid.scripts import pserve
10 from pyramid.paster import bootstrap
11 from kinto import __version__
12 from kinto.config import init
13 
14 DEFAULT_CONFIG_FILE = 'config/kinto.ini'
15 DEFAULT_PORT = 8888
16 DEFAULT_LOG_LEVEL = logging.INFO
17 DEFAULT_LOG_FORMAT = "%(levelname)-5.5s  %(message)s"
18 
19 
20 def main(args=None):
21     """The main routine."""
22     if args is None:
23         args = sys.argv[1:]
24 
25     parser = argparse.ArgumentParser(description="Kinto Command-Line "
26                                                  "Interface")
27     # XXX: deprecate this option, unnatural as first argument.
28     parser.add_argument('--ini',
29                         help='Application configuration file',
30                         dest='ini_file',
31                         required=False,
32                         default=DEFAULT_CONFIG_FILE)
33 
34     parser.add_argument('-q', '--quiet', action='store_const',
35                         const=logging.CRITICAL, dest='verbosity',
36                         help='Show only critical errors.')
37 
38     parser.add_argument('--debug', action='store_const',
39                         const=logging.DEBUG, dest='verbosity',
40                         help='Show all messages, including debug messages.')
41 
42     commands = ('init', 'start', 'migrate', 'delete-collection', 'version')
43     subparsers = parser.add_subparsers(title='subcommands',
44                                        description='Main Kinto CLI commands',
45                                        dest='subcommand',
46                                        help="Choose and run with --help")
47     subparsers.required = True
48 
49     for command in commands:
50         subparser = subparsers.add_parser(command)
51         subparser.set_defaults(which=command)
52 
53         if command == 'init':
54             subparser.add_argument('--backend',
55                                    help='{memory,redis,postgresql}',
56                                    dest='backend',
57                                    required=False,
58                                    default=None)
59         elif command == 'migrate':
60             subparser.add_argument('--dry-run',
61                                    action='store_true',
62                                    help='Simulate the migration operations '
63                                         'and show information',
64                                    dest='dry_run',
65                                    required=False,
66                                    default=False)
67         elif command == 'delete-collection':
68             subparser.add_argument('--bucket',
69                                    help='The bucket where the collection '
70                                         'belongs to.',
71                                    required=True)
72             subparser.add_argument('--collection',
73                                    help='The collection to remove.',
74                                    required=True)
75 
76         elif command == 'start':
77             subparser.add_argument('--reload',
78                                    action='store_true',
79                                    help='Restart when code or config changes',
80                                    required=False,
81                                    default=False)
82             subparser.add_argument('--port',
83                                    type=int,
84                                    help='Listening port number',
85                                    required=False,
86                                    default=DEFAULT_PORT)
87 
88     # Parse command-line arguments
89     parsed_args = vars(parser.parse_args(args))
90 
91     config_file = parsed_args['ini_file']
92     which_command = parsed_args['which']
93 
94     # Initialize logging from
95     level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL
96     logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)
97 
98     if which_command == 'init':
99         if os.path.exists(config_file):
100             print("%s already exists." % config_file, file=sys.stderr)
101             return 1
102 
103         backend = parsed_args['backend']
104         if not backend:
105             while True:
106                 prompt = ("Select the backend you would like to use: "
107                           "(1 - postgresql, 2 - redis, default - memory) ")
108                 answer = input(prompt).strip()
109                 try:
110                     backends = {"1": "postgresql", "2": "redis", "": "memory"}
111                     backend = backends[answer]
112                     break
113                 except KeyError:
114                     pass
115 
116         init(config_file, backend)
117 
118         # Install postgresql libraries if necessary
119         if backend == "postgresql":
120             try:
121                 import psycopg2  # NOQA
122             except ImportError:
123                 import pip
124                 pip.main(['install', "kinto[postgresql]"])
125         elif backend == "redis":
126             try:
127                 import kinto_redis  # NOQA
128             except ImportError:
129                 import pip
130                 pip.main(['install', "kinto[redis]"])
131 
132     elif which_command == 'migrate':
133         dry_run = parsed_args['dry_run']
134         env = bootstrap(config_file)
135         scripts.migrate(env, dry_run=dry_run)
136 
137     elif which_command == 'delete-collection':
138         env = bootstrap(config_file)
139         return scripts.delete_collection(env,
140                                          parsed_args['bucket'],
141                                          parsed_args['collection'])
142 
143     elif which_command == 'start':
144         pserve_argv = ['pserve', config_file]
145         if parsed_args['reload']:
146             pserve_argv.append('--reload')
147         pserve_argv.append('http_port=%s' % parsed_args['port'])
148         pserve.main(pserve_argv)
149 
150     elif which_command == 'version':
151         print(__version__)
152 
153     return 0
154
```
--- 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/kinto/__main__.py b/kinto/__main__.py
--- a/kinto/__main__.py
+++ b/kinto/__main__.py
@@ -4,6 +4,7 @@
 import sys
 import logging
 import logging.config
+from six.moves import input
 
 from kinto.core import scripts
 from pyramid.scripts import pserve

{"golden_diff": "diff --git a/kinto/__main__.py b/kinto/__main__.py\n--- a/kinto/__main__.py\n+++ b/kinto/__main__.py\n@@ -4,6 +4,7 @@\n import sys\n import logging\n import logging.config\n+from six.moves import input\n \n from kinto.core import scripts\n from pyramid.scripts import pserve\n", "issue": "init fails on osx at the backend selection step\nI followed the instructions given [here](https://kinto.readthedocs.io/en/stable/tutorials/install.html#from-sources), but when asked:\n\n```\n$ Select the backend you would like to use: (1 - postgresql, 2 - redis, default - memory)\n```\n\nentering `1` and `2` leads to the following error:\n\n```\nTraceback (most recent call last):\n  File \".venv/bin/kinto\", line 11, in <module>\n    load_entry_point('kinto', 'console_scripts', 'kinto')()\n  File \"/work/git/kinto/kinto/__main__.py\", line 108, in main\n    answer = input(prompt).strip()\nAttributeError: 'int' object has no attribute 'strip'\n```\n\nand entering nothing + enter will lead to the following error.\n\n```\nTraceback (most recent call last):\n  File \".venv/bin/kinto\", line 11, in <module>\n    load_entry_point('kinto', 'console_scripts', 'kinto')()\n  File \"/work/git/kinto/kinto/__main__.py\", line 108, in main\n    answer = input(prompt).strip()\n  File \"<string>\", line 0\n\n    ^\nSyntaxError: unexpected EOF while parsing\n```\n\nIt appears that the code expects a `string` but getting a number and null, therefore failing on the `.strip()` call [here](https://github.com/Kinto/kinto/blob/master/kinto/__main__.py#L108).\n\n---\n\nEntering `\"\"`, `\"1\"` and `\"2\"` works. I'm assuming that's not the way it's designed to be? \n\n", "before_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\nimport logging\nimport logging.config\n\nfrom kinto.core import scripts\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\nfrom kinto import __version__\nfrom kinto.config import init\n\nDEFAULT_CONFIG_FILE = 'config/kinto.ini'\nDEFAULT_PORT = 8888\nDEFAULT_LOG_LEVEL = logging.INFO\nDEFAULT_LOG_FORMAT = \"%(levelname)-5.5s  %(message)s\"\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto Command-Line \"\n                                                 \"Interface\")\n    # XXX: deprecate this option, unnatural as first argument.\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=DEFAULT_CONFIG_FILE)\n\n    parser.add_argument('-q', '--quiet', action='store_const',\n                        const=logging.CRITICAL, dest='verbosity',\n                        help='Show only critical errors.')\n\n    parser.add_argument('--debug', action='store_const',\n                        const=logging.DEBUG, dest='verbosity',\n                        help='Show all messages, including debug messages.')\n\n    commands = ('init', 'start', 'migrate', 'delete-collection', 'version')\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='Main Kinto CLI commands',\n                                       dest='subcommand',\n                                       help=\"Choose and run with --help\")\n    subparsers.required = True\n\n    for command in commands:\n        subparser = subparsers.add_parser(command)\n        subparser.set_defaults(which=command)\n\n        if command == 'init':\n            subparser.add_argument('--backend',\n                                   help='{memory,redis,postgresql}',\n                                   dest='backend',\n                                   required=False,\n                                   default=None)\n        elif command == 'migrate':\n            subparser.add_argument('--dry-run',\n                                   action='store_true',\n                                   help='Simulate the migration operations '\n                                        'and show information',\n                                   dest='dry_run',\n                                   required=False,\n                                   default=False)\n        elif command == 'delete-collection':\n            subparser.add_argument('--bucket',\n                                   help='The bucket where the collection '\n                                        'belongs to.',\n                                   required=True)\n            subparser.add_argument('--collection',\n                                   help='The collection to remove.',\n                                   required=True)\n\n        elif command == 'start':\n            subparser.add_argument('--reload',\n                                   action='store_true',\n                                   help='Restart when code or config changes',\n                                   required=False,\n                                   default=False)\n            subparser.add_argument('--port',\n                                   type=int,\n                                   help='Listening port number',\n                                   required=False,\n                                   default=DEFAULT_PORT)\n\n    # Parse command-line arguments\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n    which_command = parsed_args['which']\n\n    # Initialize logging from\n    level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL\n    logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)\n\n    if which_command == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exists.\" % config_file, file=sys.stderr)\n            return 1\n\n        backend = parsed_args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Select the backend you would like to use: \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[postgresql]\"])\n        elif backend == \"redis\":\n            try:\n                import kinto_redis  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[redis]\"])\n\n    elif which_command == 'migrate':\n        dry_run = parsed_args['dry_run']\n        env = bootstrap(config_file)\n        scripts.migrate(env, dry_run=dry_run)\n\n    elif which_command == 'delete-collection':\n        env = bootstrap(config_file)\n        return scripts.delete_collection(env,\n                                         parsed_args['bucket'],\n                                         parsed_args['collection'])\n\n    elif which_command == 'start':\n        pserve_argv = ['pserve', config_file]\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n        pserve_argv.append('http_port=%s' % parsed_args['port'])\n        pserve.main(pserve_argv)\n\n    elif which_command == 'version':\n        print(__version__)\n\n    return 0\n", "path": "kinto/__main__.py"}], "after_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\nimport logging\nimport logging.config\nfrom six.moves import input\n\nfrom kinto.core import scripts\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\nfrom kinto import __version__\nfrom kinto.config import init\n\nDEFAULT_CONFIG_FILE = 'config/kinto.ini'\nDEFAULT_PORT = 8888\nDEFAULT_LOG_LEVEL = logging.INFO\nDEFAULT_LOG_FORMAT = \"%(levelname)-5.5s  %(message)s\"\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto Command-Line \"\n                                                 \"Interface\")\n    # XXX: deprecate this option, unnatural as first argument.\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=DEFAULT_CONFIG_FILE)\n\n    parser.add_argument('-q', '--quiet', action='store_const',\n                        const=logging.CRITICAL, dest='verbosity',\n                        help='Show only critical errors.')\n\n    parser.add_argument('--debug', action='store_const',\n                        const=logging.DEBUG, dest='verbosity',\n                        help='Show all messages, including debug messages.')\n\n    commands = ('init', 'start', 'migrate', 'delete-collection', 'version')\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='Main Kinto CLI commands',\n                                       dest='subcommand',\n                                       help=\"Choose and run with --help\")\n    subparsers.required = True\n\n    for command in commands:\n        subparser = subparsers.add_parser(command)\n        subparser.set_defaults(which=command)\n\n        if command == 'init':\n            subparser.add_argument('--backend',\n                                   help='{memory,redis,postgresql}',\n                                   dest='backend',\n                                   required=False,\n                                   default=None)\n        elif command == 'migrate':\n            subparser.add_argument('--dry-run',\n                                   action='store_true',\n                                   help='Simulate the migration operations '\n                                        'and show information',\n                                   dest='dry_run',\n                                   required=False,\n                                   default=False)\n        elif command == 'delete-collection':\n            subparser.add_argument('--bucket',\n                                   help='The bucket where the collection '\n                                        'belongs to.',\n                                   required=True)\n            subparser.add_argument('--collection',\n                                   help='The collection to remove.',\n                                   required=True)\n\n        elif command == 'start':\n            subparser.add_argument('--reload',\n                                   action='store_true',\n                                   help='Restart when code or config changes',\n                                   required=False,\n                                   default=False)\n            subparser.add_argument('--port',\n                                   type=int,\n                                   help='Listening port number',\n                                   required=False,\n                                   default=DEFAULT_PORT)\n\n    # Parse command-line arguments\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n    which_command = parsed_args['which']\n\n    # Initialize logging from\n    level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL\n    logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)\n\n    if which_command == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exists.\" % config_file, file=sys.stderr)\n            return 1\n\n        backend = parsed_args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Select the backend you would like to use: \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[postgresql]\"])\n        elif backend == \"redis\":\n            try:\n                import kinto_redis  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[redis]\"])\n\n    elif which_command == 'migrate':\n        dry_run = parsed_args['dry_run']\n        env = bootstrap(config_file)\n        scripts.migrate(env, dry_run=dry_run)\n\n    elif which_command == 'delete-collection':\n        env = bootstrap(config_file)\n        return scripts.delete_collection(env,\n                                         parsed_args['bucket'],\n                                         parsed_args['collection'])\n\n    elif which_command == 'start':\n        pserve_argv = ['pserve', config_file]\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n        pserve_argv.append('http_port=%s' % parsed_args['port'])\n        pserve.main(pserve_argv)\n\n    elif which_command == 'version':\n        print(__version__)\n\n    return 0\n", "path": "kinto/__main__.py"}]}