We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
deprecated() utility raises AttributeError under Meinheld
The inner function of our [`deprecated()`](https://falcon.readthedocs.io/en/latest/api/util.html#falcon.deprecated) utility generator grabs the current stack frame object via [`inspect.getcurrentframe()`](https://docs.python.org/3/library/inspect.html#inspect.currentframe), and then uses its attributes to provide a more informative deprecation warning.

However, as warned in the latter's docs, this function is not guaranteed to return a valid stack frame object on all Python implementations; it may also return `None`. It seems that running Gunicorn+Meinheld workers can trigger this situation even under CPython.

Discovered using the following command line under CPython 3.7 and 3.8:
```
gunicorn --workers=8 --worker-class="egg:meinheld#gunicorn_worker" test:app
```

For instance, assigning a value to the deprecated [`Response.body`](https://falcon.readthedocs.io/en/latest/api/request_and_response_wsgi.html#falcon.Response.body) yields
```
2021-03-11 23:31:42 [FALCON] [ERROR] GET /things => Traceback (most recent call last):
  File "falcon/app.py", line 361, in falcon.app.App.__call__
  File "/tmp/benchmark/test3.py", line 13, in on_get
    resp.body = ('\nTwo things awe me most, the starry sky '
  File "falcon/util/deprecation.py", line 67, in falcon.util.deprecation.deprecated.decorator.wrapper
AttributeError: 'NoneType' object has no attribute 'f_code'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `falcon/util/deprecation.py`
Content:
```
1 # Copyright 2013 by Rackspace Hosting, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 """Miscellaneous deprecation utilities.
16 
17 This module provides decorators to mark functions and classes as deprecated.
18 """
19 
20 import functools
21 import inspect
22 import warnings
23 
24 
25 __all__ = (
26     'DeprecatedWarning',
27     'deprecated',
28     'deprecated_args',
29 )
30 
31 
32 # NOTE(kgriffs): We don't want our deprecations to be ignored by default,
33 # so create our own type.
34 #
35 # TODO(kgriffs): Revisit this decision if users complain.
36 class DeprecatedWarning(UserWarning):
37     pass
38 
39 
40 def deprecated(instructions, is_property=False):
41     """Flag a method as deprecated.
42 
43     This function returns a decorator which can be used to mark deprecated
44     functions. Applying this decorator will result in a warning being
45     emitted when the function is used.
46 
47     Args:
48         instructions (str): Specific guidance for the developer, e.g.:
49             'Please migrate to add_proxy(...)'
50         is_property (bool): If the deprecated object is a property. It
51             will omit the ``(...)`` from the generated documentation
52     """
53 
54     def decorator(func):
55 
56         object_name = 'property' if is_property else 'function'
57         post_name = '' if is_property else '(...)'
58         message = 'Call to deprecated {} {}{}. {}'.format(
59             object_name, func.__name__, post_name, instructions)
60 
61         @functools.wraps(func)
62         def wrapper(*args, **kwargs):
63             frame = inspect.currentframe().f_back
64 
65             warnings.warn_explicit(message,
66                                    category=DeprecatedWarning,
67                                    filename=inspect.getfile(frame.f_code),
68                                    lineno=frame.f_lineno)
69 
70             return func(*args, **kwargs)
71 
72         return wrapper
73 
74     return decorator
75 
76 
77 def deprecated_args(*, allowed_positional, is_method=True):
78     """Flag a method call with positional args as deprecated.
79 
80     Keyword Args:
81         allowed_positional (int): Number of allowed positional arguments
82         is_method (bool, optional): The decorated function is a method. Will
83           add one to the number of allowed positional args to account for
84           ``self``. Defaults to True.
85     """
86 
87     template = (
88         'Calls with{} positional args are deprecated.'
89         ' Please specify them as keyword arguments instead.'
90     )
91     text = ' more than {}'.format(allowed_positional) if allowed_positional else ''
92     warn_text = template.format(text)
93     if is_method:
94         allowed_positional += 1
95 
96     def deprecated_args(fn):
97         @functools.wraps(fn)
98         def wraps(*args, **kwargs):
99             if len(args) > allowed_positional:
100                 warnings.warn(warn_text, DeprecatedWarning, stacklevel=2)
101             return fn(*args, **kwargs)
102 
103         return wraps
104 
105     return deprecated_args
106
```
--- 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/falcon/util/deprecation.py b/falcon/util/deprecation.py
--- a/falcon/util/deprecation.py
+++ b/falcon/util/deprecation.py
@@ -18,7 +18,6 @@
 """
 
 import functools
-import inspect
 import warnings
 
 
@@ -60,12 +59,7 @@
 
         @functools.wraps(func)
         def wrapper(*args, **kwargs):
-            frame = inspect.currentframe().f_back
-
-            warnings.warn_explicit(message,
-                                   category=DeprecatedWarning,
-                                   filename=inspect.getfile(frame.f_code),
-                                   lineno=frame.f_lineno)
+            warnings.warn(message, category=DeprecatedWarning, stacklevel=2)
 
             return func(*args, **kwargs)

{"golden_diff": "diff --git a/falcon/util/deprecation.py b/falcon/util/deprecation.py\n--- a/falcon/util/deprecation.py\n+++ b/falcon/util/deprecation.py\n@@ -18,7 +18,6 @@\n \"\"\"\n \n import functools\n-import inspect\n import warnings\n \n \n@@ -60,12 +59,7 @@\n \n         @functools.wraps(func)\n         def wrapper(*args, **kwargs):\n-            frame = inspect.currentframe().f_back\n-\n-            warnings.warn_explicit(message,\n-                                   category=DeprecatedWarning,\n-                                   filename=inspect.getfile(frame.f_code),\n-                                   lineno=frame.f_lineno)\n+            warnings.warn(message, category=DeprecatedWarning, stacklevel=2)\n \n             return func(*args, **kwargs)\n", "issue": "deprecated() utility raises AttributeError under Meinheld\nThe inner function of our [`deprecated()`](https://falcon.readthedocs.io/en/latest/api/util.html#falcon.deprecated) utility generator grabs the current stack frame object via [`inspect.getcurrentframe()`](https://docs.python.org/3/library/inspect.html#inspect.currentframe), and then uses its attributes to provide a more informative deprecation warning.\r\n\r\nHowever, as warned in the latter's docs, this function is not guaranteed to return a valid stack frame object on all Python implementations; it may also return `None`. It seems that running Gunicorn+Meinheld workers can trigger this situation even under CPython.\r\n\r\nDiscovered using the following command line under CPython 3.7 and 3.8:\r\n```\r\ngunicorn --workers=8 --worker-class=\"egg:meinheld#gunicorn_worker\" test:app\r\n```\r\n\r\nFor instance, assigning a value to the deprecated [`Response.body`](https://falcon.readthedocs.io/en/latest/api/request_and_response_wsgi.html#falcon.Response.body) yields\r\n```\r\n2021-03-11 23:31:42 [FALCON] [ERROR] GET /things => Traceback (most recent call last):\r\n  File \"falcon/app.py\", line 361, in falcon.app.App.__call__\r\n  File \"/tmp/benchmark/test3.py\", line 13, in on_get\r\n    resp.body = ('\\nTwo things awe me most, the starry sky '\r\n  File \"falcon/util/deprecation.py\", line 67, in falcon.util.deprecation.deprecated.decorator.wrapper\r\nAttributeError: 'NoneType' object has no attribute 'f_code'\r\n```\n", "before_files": [{"content": "# Copyright 2013 by Rackspace Hosting, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Miscellaneous deprecation utilities.\n\nThis module provides decorators to mark functions and classes as deprecated.\n\"\"\"\n\nimport functools\nimport inspect\nimport warnings\n\n\n__all__ = (\n    'DeprecatedWarning',\n    'deprecated',\n    'deprecated_args',\n)\n\n\n# NOTE(kgriffs): We don't want our deprecations to be ignored by default,\n# so create our own type.\n#\n# TODO(kgriffs): Revisit this decision if users complain.\nclass DeprecatedWarning(UserWarning):\n    pass\n\n\ndef deprecated(instructions, is_property=False):\n    \"\"\"Flag a method as deprecated.\n\n    This function returns a decorator which can be used to mark deprecated\n    functions. Applying this decorator will result in a warning being\n    emitted when the function is used.\n\n    Args:\n        instructions (str): Specific guidance for the developer, e.g.:\n            'Please migrate to add_proxy(...)'\n        is_property (bool): If the deprecated object is a property. It\n            will omit the ``(...)`` from the generated documentation\n    \"\"\"\n\n    def decorator(func):\n\n        object_name = 'property' if is_property else 'function'\n        post_name = '' if is_property else '(...)'\n        message = 'Call to deprecated {} {}{}. {}'.format(\n            object_name, func.__name__, post_name, instructions)\n\n        @functools.wraps(func)\n        def wrapper(*args, **kwargs):\n            frame = inspect.currentframe().f_back\n\n            warnings.warn_explicit(message,\n                                   category=DeprecatedWarning,\n                                   filename=inspect.getfile(frame.f_code),\n                                   lineno=frame.f_lineno)\n\n            return func(*args, **kwargs)\n\n        return wrapper\n\n    return decorator\n\n\ndef deprecated_args(*, allowed_positional, is_method=True):\n    \"\"\"Flag a method call with positional args as deprecated.\n\n    Keyword Args:\n        allowed_positional (int): Number of allowed positional arguments\n        is_method (bool, optional): The decorated function is a method. Will\n          add one to the number of allowed positional args to account for\n          ``self``. Defaults to True.\n    \"\"\"\n\n    template = (\n        'Calls with{} positional args are deprecated.'\n        ' Please specify them as keyword arguments instead.'\n    )\n    text = ' more than {}'.format(allowed_positional) if allowed_positional else ''\n    warn_text = template.format(text)\n    if is_method:\n        allowed_positional += 1\n\n    def deprecated_args(fn):\n        @functools.wraps(fn)\n        def wraps(*args, **kwargs):\n            if len(args) > allowed_positional:\n                warnings.warn(warn_text, DeprecatedWarning, stacklevel=2)\n            return fn(*args, **kwargs)\n\n        return wraps\n\n    return deprecated_args\n", "path": "falcon/util/deprecation.py"}], "after_files": [{"content": "# Copyright 2013 by Rackspace Hosting, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Miscellaneous deprecation utilities.\n\nThis module provides decorators to mark functions and classes as deprecated.\n\"\"\"\n\nimport functools\nimport warnings\n\n\n__all__ = (\n    'DeprecatedWarning',\n    'deprecated',\n    'deprecated_args',\n)\n\n\n# NOTE(kgriffs): We don't want our deprecations to be ignored by default,\n# so create our own type.\n#\n# TODO(kgriffs): Revisit this decision if users complain.\nclass DeprecatedWarning(UserWarning):\n    pass\n\n\ndef deprecated(instructions, is_property=False):\n    \"\"\"Flag a method as deprecated.\n\n    This function returns a decorator which can be used to mark deprecated\n    functions. Applying this decorator will result in a warning being\n    emitted when the function is used.\n\n    Args:\n        instructions (str): Specific guidance for the developer, e.g.:\n            'Please migrate to add_proxy(...)'\n        is_property (bool): If the deprecated object is a property. It\n            will omit the ``(...)`` from the generated documentation\n    \"\"\"\n\n    def decorator(func):\n\n        object_name = 'property' if is_property else 'function'\n        post_name = '' if is_property else '(...)'\n        message = 'Call to deprecated {} {}{}. {}'.format(\n            object_name, func.__name__, post_name, instructions)\n\n        @functools.wraps(func)\n        def wrapper(*args, **kwargs):\n            warnings.warn(message, category=DeprecatedWarning, stacklevel=2)\n\n            return func(*args, **kwargs)\n\n        return wrapper\n\n    return decorator\n\n\ndef deprecated_args(*, allowed_positional, is_method=True):\n    \"\"\"Flag a method call with positional args as deprecated.\n\n    Keyword Args:\n        allowed_positional (int): Number of allowed positional arguments\n        is_method (bool, optional): The decorated function is a method. Will\n          add one to the number of allowed positional args to account for\n          ``self``. Defaults to True.\n    \"\"\"\n\n    template = (\n        'Calls with{} positional args are deprecated.'\n        ' Please specify them as keyword arguments instead.'\n    )\n    text = ' more than {}'.format(allowed_positional) if allowed_positional else ''\n    warn_text = template.format(text)\n    if is_method:\n        allowed_positional += 1\n\n    def deprecated_args(fn):\n        @functools.wraps(fn)\n        def wraps(*args, **kwargs):\n            if len(args) > allowed_positional:\n                warnings.warn(warn_text, DeprecatedWarning, stacklevel=2)\n            return fn(*args, **kwargs)\n\n        return wraps\n\n    return deprecated_args\n", "path": "falcon/util/deprecation.py"}]}