We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Setup.py uses the imp module that is deprecated
while trying to run `python setup.py test` I get the warning
`DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses`

Since python 2 is no longer supported I think we can migrate to `importlib`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 import glob
2 import imp
3 import io
4 import os
5 from os import path
6 import re
7 import sys
8 
9 from setuptools import Extension, find_packages, setup
10 
11 MYDIR = path.abspath(os.path.dirname(__file__))
12 
13 VERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))
14 VERSION = VERSION.__version__
15 
16 REQUIRES = []
17 
18 try:
19     sys.pypy_version_info
20     PYPY = True
21 except AttributeError:
22     PYPY = False
23 
24 if PYPY:
25     CYTHON = False
26 else:
27     try:
28         from Cython.Distutils import build_ext
29         CYTHON = True
30     except ImportError:
31         # TODO(kgriffs): pip now ignores all output, so the user
32         # may not see this message. See also:
33         #
34         #   https://github.com/pypa/pip/issues/2732
35         #
36         print('\nNOTE: Cython not installed. '
37               'Falcon will still work fine, but may run '
38               'a bit slower.\n')
39         CYTHON = False
40 
41 if CYTHON:
42     def list_modules(dirname, pattern):
43         filenames = glob.glob(path.join(dirname, pattern))
44 
45         module_names = []
46         for name in filenames:
47             module, ext = path.splitext(path.basename(name))
48             if module != '__init__':
49                 module_names.append((module, ext))
50 
51         return module_names
52 
53     package_names = [
54         'falcon',
55         'falcon.cyutil',
56         'falcon.media',
57         'falcon.routing',
58         'falcon.util',
59         'falcon.vendor.mimeparse',
60     ]
61 
62     modules_to_exclude = [
63         # NOTE(kgriffs): Cython does not handle dynamically-created async
64         #   methods correctly, so we do not cythonize the following modules.
65         'falcon.hooks',
66         # NOTE(vytas): Middleware classes cannot be cythonized until
67         #   asyncio.iscoroutinefunction recognizes cythonized coroutines:
68         #   * https://github.com/cython/cython/issues/2273
69         #   * https://bugs.python.org/issue38225
70         'falcon.middlewares',
71         'falcon.responders',
72         'falcon.util.sync',
73     ]
74 
75     cython_package_names = frozenset([
76         'falcon.cyutil',
77     ])
78 
79     ext_modules = [
80         Extension(
81             package + '.' + module,
82             [path.join(*(package.split('.') + [module + ext]))]
83         )
84         for package in package_names
85         for module, ext in list_modules(
86             path.join(MYDIR, *package.split('.')),
87             ('*.pyx' if package in cython_package_names else '*.py'))
88         if (package + '.' + module) not in modules_to_exclude
89     ]
90 
91     cmdclass = {'build_ext': build_ext}
92 
93 else:
94     cmdclass = {}
95     ext_modules = []
96 
97 
98 def load_description():
99     in_patron_list = False
100     in_patron_replacement = False
101     in_raw = False
102 
103     description_lines = []
104 
105     # NOTE(kgriffs): PyPI does not support the raw directive
106     for readme_line in io.open('README.rst', 'r', encoding='utf-8'):
107 
108         # NOTE(vytas): The patron list largely builds upon raw sections
109         if readme_line.startswith('.. Patron list starts'):
110             in_patron_list = True
111             in_patron_replacement = True
112             continue
113         elif in_patron_list:
114             if not readme_line.strip():
115                 in_patron_replacement = False
116             elif in_patron_replacement:
117                 description_lines.append(readme_line.lstrip())
118             if readme_line.startswith('.. Patron list ends'):
119                 in_patron_list = False
120             continue
121         elif readme_line.startswith('.. raw::'):
122             in_raw = True
123         elif in_raw:
124             if readme_line and not re.match(r'\s', readme_line):
125                 in_raw = False
126 
127         if not in_raw:
128             description_lines.append(readme_line)
129 
130     return ''.join(description_lines)
131 
132 
133 setup(
134     name='falcon',
135     version=VERSION,
136     description='An unladen web framework for building APIs and app backends.',
137     long_description=load_description(),
138     long_description_content_type='text/x-rst',
139     classifiers=[
140         'Development Status :: 5 - Production/Stable',
141         'Environment :: Web Environment',
142         'Natural Language :: English',
143         'Intended Audience :: Developers',
144         'Intended Audience :: System Administrators',
145         'License :: OSI Approved :: Apache Software License',
146         'Operating System :: MacOS :: MacOS X',
147         'Operating System :: Microsoft :: Windows',
148         'Operating System :: POSIX',
149         'Topic :: Internet :: WWW/HTTP :: WSGI',
150         'Topic :: Software Development :: Libraries :: Application Frameworks',
151         'Programming Language :: Python',
152         'Programming Language :: Python :: Implementation :: CPython',
153         'Programming Language :: Python :: Implementation :: PyPy',
154         'Programming Language :: Python :: 3',
155         'Programming Language :: Python :: 3.5',
156         'Programming Language :: Python :: 3.6',
157         'Programming Language :: Python :: 3.7',
158         'Programming Language :: Python :: 3.8',
159     ],
160     keywords='wsgi web api framework rest http cloud',
161     author='Kurt Griffiths',
162     author_email='mail@kgriffs.com',
163     url='https://falconframework.org',
164     license='Apache 2.0',
165     packages=find_packages(exclude=['tests']),
166     include_package_data=True,
167     zip_safe=False,
168     python_requires='>=3.5',
169     install_requires=REQUIRES,
170     cmdclass=cmdclass,
171     ext_modules=ext_modules,
172     tests_require=['testtools', 'requests', 'pyyaml', 'pytest', 'pytest-runner'],
173     entry_points={
174         'console_scripts': [
175             'falcon-bench = falcon.cmd.bench:main',
176             'falcon-print-routes = falcon.cmd.print_routes:main'
177         ]
178     }
179 )
180
```
--- 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/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
 import glob
-import imp
+import importlib
 import io
 import os
 from os import path
@@ -10,7 +10,7 @@
 
 MYDIR = path.abspath(os.path.dirname(__file__))
 
-VERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))
+VERSION = importlib.import_module('falcon.version')
 VERSION = VERSION.__version__
 
 REQUIRES = []

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -1,5 +1,5 @@\n import glob\n-import imp\n+import importlib\n import io\n import os\n from os import path\n@@ -10,7 +10,7 @@\n \n MYDIR = path.abspath(os.path.dirname(__file__))\n \n-VERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))\n+VERSION = importlib.import_module('falcon.version')\n VERSION = VERSION.__version__\n \n REQUIRES = []\n", "issue": "Setup.py uses the imp module that is deprecated\nwhile trying to run `python setup.py test` I get the warning\r\n`DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses`\r\n\r\nSince python 2 is no longer supported I think we can migrate to `importlib`\n", "before_files": [{"content": "import glob\nimport imp\nimport io\nimport os\nfrom os import path\nimport re\nimport sys\n\nfrom setuptools import Extension, find_packages, setup\n\nMYDIR = path.abspath(os.path.dirname(__file__))\n\nVERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))\nVERSION = VERSION.__version__\n\nREQUIRES = []\n\ntry:\n    sys.pypy_version_info\n    PYPY = True\nexcept AttributeError:\n    PYPY = False\n\nif PYPY:\n    CYTHON = False\nelse:\n    try:\n        from Cython.Distutils import build_ext\n        CYTHON = True\n    except ImportError:\n        # TODO(kgriffs): pip now ignores all output, so the user\n        # may not see this message. See also:\n        #\n        #   https://github.com/pypa/pip/issues/2732\n        #\n        print('\\nNOTE: Cython not installed. '\n              'Falcon will still work fine, but may run '\n              'a bit slower.\\n')\n        CYTHON = False\n\nif CYTHON:\n    def list_modules(dirname, pattern):\n        filenames = glob.glob(path.join(dirname, pattern))\n\n        module_names = []\n        for name in filenames:\n            module, ext = path.splitext(path.basename(name))\n            if module != '__init__':\n                module_names.append((module, ext))\n\n        return module_names\n\n    package_names = [\n        'falcon',\n        'falcon.cyutil',\n        'falcon.media',\n        'falcon.routing',\n        'falcon.util',\n        'falcon.vendor.mimeparse',\n    ]\n\n    modules_to_exclude = [\n        # NOTE(kgriffs): Cython does not handle dynamically-created async\n        #   methods correctly, so we do not cythonize the following modules.\n        'falcon.hooks',\n        # NOTE(vytas): Middleware classes cannot be cythonized until\n        #   asyncio.iscoroutinefunction recognizes cythonized coroutines:\n        #   * https://github.com/cython/cython/issues/2273\n        #   * https://bugs.python.org/issue38225\n        'falcon.middlewares',\n        'falcon.responders',\n        'falcon.util.sync',\n    ]\n\n    cython_package_names = frozenset([\n        'falcon.cyutil',\n    ])\n\n    ext_modules = [\n        Extension(\n            package + '.' + module,\n            [path.join(*(package.split('.') + [module + ext]))]\n        )\n        for package in package_names\n        for module, ext in list_modules(\n            path.join(MYDIR, *package.split('.')),\n            ('*.pyx' if package in cython_package_names else '*.py'))\n        if (package + '.' + module) not in modules_to_exclude\n    ]\n\n    cmdclass = {'build_ext': build_ext}\n\nelse:\n    cmdclass = {}\n    ext_modules = []\n\n\ndef load_description():\n    in_patron_list = False\n    in_patron_replacement = False\n    in_raw = False\n\n    description_lines = []\n\n    # NOTE(kgriffs): PyPI does not support the raw directive\n    for readme_line in io.open('README.rst', 'r', encoding='utf-8'):\n\n        # NOTE(vytas): The patron list largely builds upon raw sections\n        if readme_line.startswith('.. Patron list starts'):\n            in_patron_list = True\n            in_patron_replacement = True\n            continue\n        elif in_patron_list:\n            if not readme_line.strip():\n                in_patron_replacement = False\n            elif in_patron_replacement:\n                description_lines.append(readme_line.lstrip())\n            if readme_line.startswith('.. Patron list ends'):\n                in_patron_list = False\n            continue\n        elif readme_line.startswith('.. raw::'):\n            in_raw = True\n        elif in_raw:\n            if readme_line and not re.match(r'\\s', readme_line):\n                in_raw = False\n\n        if not in_raw:\n            description_lines.append(readme_line)\n\n    return ''.join(description_lines)\n\n\nsetup(\n    name='falcon',\n    version=VERSION,\n    description='An unladen web framework for building APIs and app backends.',\n    long_description=load_description(),\n    long_description_content_type='text/x-rst',\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Web Environment',\n        'Natural Language :: English',\n        'Intended Audience :: Developers',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: Apache Software License',\n        'Operating System :: MacOS :: MacOS X',\n        'Operating System :: Microsoft :: Windows',\n        'Operating System :: POSIX',\n        'Topic :: Internet :: WWW/HTTP :: WSGI',\n        'Topic :: Software Development :: Libraries :: Application Frameworks',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: Implementation :: CPython',\n        'Programming Language :: Python :: Implementation :: PyPy',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n    ],\n    keywords='wsgi web api framework rest http cloud',\n    author='Kurt Griffiths',\n    author_email='mail@kgriffs.com',\n    url='https://falconframework.org',\n    license='Apache 2.0',\n    packages=find_packages(exclude=['tests']),\n    include_package_data=True,\n    zip_safe=False,\n    python_requires='>=3.5',\n    install_requires=REQUIRES,\n    cmdclass=cmdclass,\n    ext_modules=ext_modules,\n    tests_require=['testtools', 'requests', 'pyyaml', 'pytest', 'pytest-runner'],\n    entry_points={\n        'console_scripts': [\n            'falcon-bench = falcon.cmd.bench:main',\n            'falcon-print-routes = falcon.cmd.print_routes:main'\n        ]\n    }\n)\n", "path": "setup.py"}], "after_files": [{"content": "import glob\nimport importlib\nimport io\nimport os\nfrom os import path\nimport re\nimport sys\n\nfrom setuptools import Extension, find_packages, setup\n\nMYDIR = path.abspath(os.path.dirname(__file__))\n\nVERSION = importlib.import_module('falcon.version')\nVERSION = VERSION.__version__\n\nREQUIRES = []\n\ntry:\n    sys.pypy_version_info\n    PYPY = True\nexcept AttributeError:\n    PYPY = False\n\nif PYPY:\n    CYTHON = False\nelse:\n    try:\n        from Cython.Distutils import build_ext\n        CYTHON = True\n    except ImportError:\n        # TODO(kgriffs): pip now ignores all output, so the user\n        # may not see this message. See also:\n        #\n        #   https://github.com/pypa/pip/issues/2732\n        #\n        print('\\nNOTE: Cython not installed. '\n              'Falcon will still work fine, but may run '\n              'a bit slower.\\n')\n        CYTHON = False\n\nif CYTHON:\n    def list_modules(dirname, pattern):\n        filenames = glob.glob(path.join(dirname, pattern))\n\n        module_names = []\n        for name in filenames:\n            module, ext = path.splitext(path.basename(name))\n            if module != '__init__':\n                module_names.append((module, ext))\n\n        return module_names\n\n    package_names = [\n        'falcon',\n        'falcon.cyutil',\n        'falcon.media',\n        'falcon.routing',\n        'falcon.util',\n        'falcon.vendor.mimeparse',\n    ]\n\n    modules_to_exclude = [\n        # NOTE(kgriffs): Cython does not handle dynamically-created async\n        #   methods correctly, so we do not cythonize the following modules.\n        'falcon.hooks',\n        # NOTE(vytas): Middleware classes cannot be cythonized until\n        #   asyncio.iscoroutinefunction recognizes cythonized coroutines:\n        #   * https://github.com/cython/cython/issues/2273\n        #   * https://bugs.python.org/issue38225\n        'falcon.middlewares',\n        'falcon.responders',\n        'falcon.util.sync',\n    ]\n\n    cython_package_names = frozenset([\n        'falcon.cyutil',\n    ])\n\n    ext_modules = [\n        Extension(\n            package + '.' + module,\n            [path.join(*(package.split('.') + [module + ext]))]\n        )\n        for package in package_names\n        for module, ext in list_modules(\n            path.join(MYDIR, *package.split('.')),\n            ('*.pyx' if package in cython_package_names else '*.py'))\n        if (package + '.' + module) not in modules_to_exclude\n    ]\n\n    cmdclass = {'build_ext': build_ext}\n\nelse:\n    cmdclass = {}\n    ext_modules = []\n\n\ndef load_description():\n    in_patron_list = False\n    in_patron_replacement = False\n    in_raw = False\n\n    description_lines = []\n\n    # NOTE(kgriffs): PyPI does not support the raw directive\n    for readme_line in io.open('README.rst', 'r', encoding='utf-8'):\n\n        # NOTE(vytas): The patron list largely builds upon raw sections\n        if readme_line.startswith('.. Patron list starts'):\n            in_patron_list = True\n            in_patron_replacement = True\n            continue\n        elif in_patron_list:\n            if not readme_line.strip():\n                in_patron_replacement = False\n            elif in_patron_replacement:\n                description_lines.append(readme_line.lstrip())\n            if readme_line.startswith('.. Patron list ends'):\n                in_patron_list = False\n            continue\n        elif readme_line.startswith('.. raw::'):\n            in_raw = True\n        elif in_raw:\n            if readme_line and not re.match(r'\\s', readme_line):\n                in_raw = False\n\n        if not in_raw:\n            description_lines.append(readme_line)\n\n    return ''.join(description_lines)\n\n\nsetup(\n    name='falcon',\n    version=VERSION,\n    description='An unladen web framework for building APIs and app backends.',\n    long_description=load_description(),\n    long_description_content_type='text/x-rst',\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Web Environment',\n        'Natural Language :: English',\n        'Intended Audience :: Developers',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: Apache Software License',\n        'Operating System :: MacOS :: MacOS X',\n        'Operating System :: Microsoft :: Windows',\n        'Operating System :: POSIX',\n        'Topic :: Internet :: WWW/HTTP :: WSGI',\n        'Topic :: Software Development :: Libraries :: Application Frameworks',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: Implementation :: CPython',\n        'Programming Language :: Python :: Implementation :: PyPy',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n    ],\n    keywords='wsgi web api framework rest http cloud',\n    author='Kurt Griffiths',\n    author_email='mail@kgriffs.com',\n    url='https://falconframework.org',\n    license='Apache 2.0',\n    packages=find_packages(exclude=['tests']),\n    include_package_data=True,\n    zip_safe=False,\n    python_requires='>=3.5',\n    install_requires=REQUIRES,\n    cmdclass=cmdclass,\n    ext_modules=ext_modules,\n    tests_require=['testtools', 'requests', 'pyyaml', 'pytest', 'pytest-runner'],\n    entry_points={\n        'console_scripts': [\n            'falcon-bench = falcon.cmd.bench:main',\n            'falcon-print-routes = falcon.cmd.print_routes:main'\n        ]\n    }\n)\n", "path": "setup.py"}]}