Django-storages: RemovedInDjango40Warning: force_text() is deprecated in favor of force_str()

Created on 21 Dec 2019  路  2Comments  路  Source: jschneier/django-storages

After recently upgrading to Django 3.0, I started to receive deprecation warnings for force_text(). As noted in the release notes:

django.utils.encoding.force_text() and smart_text()
The smart_text() and force_text() aliases (since Django 2.0) of smart_str() and force_str() are deprecated. Ignore this deprecation if your code supports Python 2 as the behavior of smart_str() and force_str() is different there.

I noted that django-storages still supports Python 2.7, but I'm not sure if support for it is going to be dropped soon or otherwise. If we're interested to address this, i'll be more than happy to follow up with a PR.

EDIT: Python 2.7 will be unsupported after January 1, 2020.

Most helpful comment

Hi @jschneier

Would you consider looking at the fix put in place for this? When I run my project's test suite, I receive hundreds of warnings from django-storages that look like the OP. The output is too noisy to be useful and could easily hide other legitimate warnings I need to fix in my own projects.

Python 2 is now officially EOL, so there is less need to continue supporting it.

Using pypinfo, here are the pip statistics for this project from the last month. You can see that Python 2 downloads make up less than 18% and has been dropping.

| python_version | percent | download_count |
| -------------- | ------: | -------------: |
| 3.6 | 38.29% | 298,681 |
| 3.7 | 29.31% | 228,595 |
| 2.7 | 17.68% | 137,931 |
| 3.5 | 8.56% | 66,774 |
| 3.8 | 5.47% | 42,659 |
| 3.4 | 0.67% | 5,212 |
| 3.9 | 0.01% | 109 |
| 2.6 | 0.00% | 6 |
| 3.2 | 0.00% | 2 |
| Total | | 779,969 |

EDIT: Users that wish to stay on Python 2.7 can continue to use the latest version of django-storages that supports Python 2. So they won't be left high and dry.

All 2 comments

PR #709 addresses this issue.

Hi @jschneier

Would you consider looking at the fix put in place for this? When I run my project's test suite, I receive hundreds of warnings from django-storages that look like the OP. The output is too noisy to be useful and could easily hide other legitimate warnings I need to fix in my own projects.

Python 2 is now officially EOL, so there is less need to continue supporting it.

Using pypinfo, here are the pip statistics for this project from the last month. You can see that Python 2 downloads make up less than 18% and has been dropping.

| python_version | percent | download_count |
| -------------- | ------: | -------------: |
| 3.6 | 38.29% | 298,681 |
| 3.7 | 29.31% | 228,595 |
| 2.7 | 17.68% | 137,931 |
| 3.5 | 8.56% | 66,774 |
| 3.8 | 5.47% | 42,659 |
| 3.4 | 0.67% | 5,212 |
| 3.9 | 0.01% | 109 |
| 2.6 | 0.00% | 6 |
| 3.2 | 0.00% | 2 |
| Total | | 779,969 |

EDIT: Users that wish to stay on Python 2.7 can continue to use the latest version of django-storages that supports Python 2. So they won't be left high and dry.

Was this page helpful?
0 / 5 - 0 ratings