prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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'
  ```
  
  </issue>
  <code>
  [start of falcon/util/deprecation.py]
  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 of falcon/util/deprecation.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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)
  
verification_info: {"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"}]}