falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.53k stars 945 forks source link

DeprecatedWarning: Call to deprecated property body #1905

Closed wilwet closed 3 years ago

wilwet commented 3 years ago

I get the following warning, any idea?

.local/lib/python3.7/site-packages/gunicorn/workers/sync.py:179: DeprecatedWarning: Call to deprecated property body. Please use text instead. respiter = self.wsgi(environ, resp.start_response)

using gunicorn 20.1.0 and falcon 3.0.0

open-collective-bot[bot] commented 3 years ago

Hi :wave:,

Thanks for using Falcon. The large amount of time and effort needed to maintain the project and develop new features is not sustainable without the generous financial support of community members like you.

Please consider helping us secure the future of the Falcon framework with a one-time or recurring donation.

Thank you for your support!

vytas7 commented 3 years ago

Hi @wilwet ! Yes, it is basically as the deprecation warning reads :slightly_smiling_face:

Call to deprecated property body. Please use text instead.

To elaborate, in Falcon 3.0, resp.body was renamed to resp.text. So if you had your responder along the lines of,

def on_get(self, req, resp):
    # Simply rename resp.body to resp.text:
    # resp.body = 'Hello, World!\n'
    resp.text = 'Hello, World!\n'

    # ...

You may also want to check this brief overview: When would I use media, data, and stream?

Hope this sheds some light on the subject, or did you have something else in mind?

wilwet commented 3 years ago

Thank you for your swift response and your great support! This fixes the warnings.

vytas7 commented 3 years ago

Awesome sauce, closing this then.

Happy tinkering!