[Django] #27795: Audit force_text invocations

49 views
Skip to first unread message

Django

unread,
Jan 30, 2017, 12:13:44 PM1/30/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude | Owner: Claude Paroz
Paroz |
Type: | Status: assigned
Cleanup/optimization |
Component: Utilities | Version: master
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`django.utils.encoding.force_text` is called many times in Django code for
several use cases:
- force the evaluation of a lazy string
- convert bytes or a bytestring (PY2) to str
- convert an object to its string representation

A global audit is needed to clean that usage, also considering that Python
3 native strings are more wildly used.
I'm working on it currently.

--
Ticket URL: <https://code.djangoproject.com/ticket/27795>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 30, 2017, 3:11:28 PM1/30/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"ccfd1295f986cdf628d774937d0b38a14584721f" ccfd1295]:
{{{
#!CommitTicketReference repository=""
revision="ccfd1295f986cdf628d774937d0b38a14584721f"
Refs #27795 -- Prevented SafeText from losing safe status on str()

This will allow to replace force_text() by str() in several places (as one
of
the features of force_text is to keep the safe status).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:1>

Django

unread,
Feb 6, 2017, 11:37:29 AM2/6/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"2757209c9de3764364a8e8af39cefa2445312546" 2757209c]:
{{{
#!CommitTicketReference repository=""
revision="2757209c9de3764364a8e8af39cefa2445312546"
Refs #27795 -- Removed force_text from templatize function
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:2>

Django

unread,
Feb 7, 2017, 11:15:25 AM2/7/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"3a148f958dddd97c1379081118c30fbede6b6bc4" 3a148f95]:
{{{
#!CommitTicketReference repository=""
revision="3a148f958dddd97c1379081118c30fbede6b6bc4"
Refs #27795 -- Removed force_text from the template layer

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:3>

Django

unread,
Mar 4, 2017, 12:19:26 PM3/4/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"8346680e1ca4a8ddc8190baf3f5f944f6418d5cf" 8346680e]:
{{{
#!CommitTicketReference repository=""
revision="8346680e1ca4a8ddc8190baf3f5f944f6418d5cf"
Refs #27795 -- Removed unneeded force_text calls

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:4>

Django

unread,
Apr 17, 2017, 8:22:26 AM4/17/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"e5dce7b0fbd2965e524ce97114f501319ec2bb6f" e5dce7b0]:
{{{
#!CommitTicketReference repository=""
revision="e5dce7b0fbd2965e524ce97114f501319ec2bb6f"
Refs #27795 -- Removed unneeded force_text calls from the Oracle backend.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:5>

Django

unread,
Apr 27, 2017, 3:11:20 AM4/27/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"301de774c21d055e9e5a7073e5bffdb52bc71079" 301de77]:
{{{
#!CommitTicketReference repository=""
revision="301de774c21d055e9e5a7073e5bffdb52bc71079"
Refs #27795 -- Replaced many force_text() with str()

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:6>

Django

unread,
Apr 27, 2017, 3:51:17 AM4/27/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"a8343fe7bf0ec237d8f77ba4e729ae093388b75f" a8343fe7]:
{{{
#!CommitTicketReference repository=""
revision="a8343fe7bf0ec237d8f77ba4e729ae093388b75f"
Refs #27795 -- Replaced force_text() with str() in feed generators
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:7>

Django

unread,
May 1, 2017, 8:48:02 AM5/1/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b39aabc6c6b84cbe4005f3fdf3b9c0c4307afc76" b39aabc]:
{{{
#!CommitTicketReference repository=""
revision="b39aabc6c6b84cbe4005f3fdf3b9c0c4307afc76"
Refs #27795 -- Reworked get_or_create test erroneously mixing bytes and
str.

As CharField.to_python() now always calls str(), assigning bytes to a
CharField is no longer correct usage. Doing so results in a warning:

django/db/models/fields/__init__.py:1061: BytesWarning: str() on a bytes
instance

Use a unique constraint violation to trigger the database error instead.

Warning introduced in 301de774c21d055e9e5a7073e5bffdb52bc71079.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:8>

Django

unread,
May 8, 2017, 1:47:29 PM5/8/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"d842ada30524abf410a4de3fc1e539450173800f" d842ada]:
{{{
#!CommitTicketReference repository=""
revision="d842ada30524abf410a4de3fc1e539450173800f"
Refs #27795 -- Stopped converting integer format settings to str in
JS/JSON i18n views

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:9>

Django

unread,
May 10, 2017, 4:41:09 PM5/10/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"f87256b15e375c6c57fe425c33ae23e116da3e84" f87256b1]:
{{{
#!CommitTicketReference repository=""
revision="f87256b15e375c6c57fe425c33ae23e116da3e84"
Refs #27795 -- Replaced force_text() with str() in contrib.messages

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:10>

Django

unread,
Jun 5, 2017, 12:34:49 PM6/5/17
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"45bbb9aae0e7af6cd16fa4fe410219d4d65f829c" 45bbb9aa]:
{{{
#!CommitTicketReference repository=""
revision="45bbb9aae0e7af6cd16fa4fe410219d4d65f829c"
Refs #27795 -- Removed force_text() usage in serialization framework
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:11>

Django

unread,
Jan 31, 2018, 10:35:26 AM1/31/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"6b2f8fb91c7adab123156e185db2efe31e41b628" 6b2f8fb9]:
{{{
#!CommitTicketReference repository=""
revision="6b2f8fb91c7adab123156e185db2efe31e41b628"
Refs #27795 -- Replaced force_text() usage in django.core.management.

Use decode() since Popen.communicate() always returns bytes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:12>

Django

unread,
Feb 1, 2018, 12:36:42 PM2/1/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"16c5a334ff3ad9d8b3cd1314562c7af20a2a7c7d" 16c5a334]:
{{{
#!CommitTicketReference repository=""
revision="16c5a334ff3ad9d8b3cd1314562c7af20a2a7c7d"
Refs #27795 -- Replaced force_text/bytes() with decode()/encode() in
password hashers.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:13>

Django

unread,
Feb 2, 2018, 2:58:16 AM2/2/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"6a039800db7ce4aa4c1afecd26791c43ddde8920" 6a039800]:
{{{
#!CommitTicketReference repository=""
revision="6a039800db7ce4aa4c1afecd26791c43ddde8920"
Refs #27795 -- Replaced force_bytes() usage in django.core.cache.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:14>

Django

unread,
Feb 7, 2018, 12:48:09 PM2/7/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b38532cd6be6ea91b47fd93e9cbaae4aa10015fc" b38532c]:
{{{
#!CommitTicketReference repository=""
revision="b38532cd6be6ea91b47fd93e9cbaae4aa10015fc"
Refs #27795 -- Replaced force_bytes() usage in django.core.signing.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:15>

Django

unread,
Feb 7, 2018, 2:20:27 PM2/7/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"fa75b2cb512409116b6f1b5229d6f99074d8e452" fa75b2c]:
{{{
#!CommitTicketReference repository=""
revision="fa75b2cb512409116b6f1b5229d6f99074d8e452"
Refs #27795 -- Removed force_bytes/text() usage in tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:16>

Django

unread,
Feb 7, 2018, 3:21:28 PM2/7/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7d96f0c49ab750799860e42716d7105e11de44de" 7d96f0c4]:
{{{
#!CommitTicketReference repository=""
revision="7d96f0c49ab750799860e42716d7105e11de44de"
Refs #27795 -- Replaced force_bytes() usage in django.http.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:17>

Django

unread,
Feb 10, 2018, 11:25:36 AM2/10/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jon Dufresne <jon.dufresne@…>):

In [changeset:"968329b5c254fc0d77bde78f81b8bcd17655b14e" 968329b]:
{{{
#!CommitTicketReference repository=""
revision="968329b5c254fc0d77bde78f81b8bcd17655b14e"
Refs #27795 -- Replaced force_text() calls with str() in
django.utils.html.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:18>

Django

unread,
Feb 10, 2018, 11:26:08 AM2/10/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"1f3852b708feb2a3e20bf7a65f6cab9366cf7296" 1f3852b]:
{{{
#!CommitTicketReference repository=""
revision="1f3852b708feb2a3e20bf7a65f6cab9366cf7296"
Refs #27795 -- Removed force_bytes() usage in
django/template/loaders/cached.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:19>

Django

unread,
Feb 10, 2018, 11:44:56 AM2/10/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"919d59811f10f5a0101aac7b854aad5ec13d1b2a" 919d5981]:
{{{
#!CommitTicketReference repository=""
revision="919d59811f10f5a0101aac7b854aad5ec13d1b2a"
Refs #27795 -- Removed force_text() usage in django/test/testcases.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:20>

Django

unread,
Feb 12, 2018, 12:37:03 PM2/12/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b8a41a2872624a6d9e61308932dd81d001e31eb9" b8a41a28]:
{{{
#!CommitTicketReference repository=""
revision="b8a41a2872624a6d9e61308932dd81d001e31eb9"
Refs #27795 -- Removed force_bytes() in django.test.client where possible.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:21>

Django

unread,
Aug 28, 2018, 7:56:40 AM8/28/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"90f3ef332b0274d066c9bc2d7f41242f755f7187" 90f3ef3]:
{{{
#!CommitTicketReference repository=""
revision="90f3ef332b0274d066c9bc2d7f41242f755f7187"
Refs #27795 -- Removed force_bytes()/smart_text() from model fields.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:22>

Django

unread,
Aug 28, 2018, 8:03:46 AM8/28/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"ee184e13cba1dbb3ec6fc5ec32ec035ceebcb991" ee184e1]:
{{{
#!CommitTicketReference repository=""
revision="ee184e13cba1dbb3ec6fc5ec32ec035ceebcb991"
Refs #27795 -- Removed force_bytes() usage in django/utils/cache.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:23>

Django

unread,
Aug 31, 2018, 11:00:38 AM8/31/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"cc79c7ee637e65c8da27e56d746c87903d5ec901" cc79c7ee]:
{{{
#!CommitTicketReference repository=""
revision="cc79c7ee637e65c8da27e56d746c87903d5ec901"
Refs #27795 -- Removed force_text() in Model._get_FIELD_display().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:24>

Django

unread,
Sep 25, 2018, 9:53:50 AM9/25/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"1d65ddd9c357b7018c616ecb0369d47eeb92c3a3" 1d65ddd9]:
{{{
#!CommitTicketReference repository=""
revision="1d65ddd9c357b7018c616ecb0369d47eeb92c3a3"
Refs #27795 -- Removed force_bytes() usage in db/backends/utils.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:25>

Django

unread,
Sep 25, 2018, 9:54:28 AM9/25/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"abeed587b119197270a885830619694b2c5ba1f1" abeed587]:
{{{
#!CommitTicketReference repository=""
revision="abeed587b119197270a885830619694b2c5ba1f1"
Refs #27795 -- Removed force_bytes() usage in db/backends/base/schema.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:26>

Django

unread,
Sep 25, 2018, 11:28:04 AM9/25/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"bb81c22d90e5eb168544670ead1a13aa9695fed5" bb81c22]:
{{{
#!CommitTicketReference repository=""
revision="bb81c22d90e5eb168544670ead1a13aa9695fed5"
Refs #27795 -- Removed force_bytes() usage in utils/_os.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:27>

Django

unread,
Sep 26, 2018, 11:17:45 AM9/26/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8d8735035637805201eb8242dfa86ee0cfe9776a" 8d873503]:
{{{
#!CommitTicketReference repository=""
revision="8d8735035637805201eb8242dfa86ee0cfe9776a"


Refs #27795 -- Removed force_bytes() usage in

contrib/auth/handlers/modwsgi.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:28>

Django

unread,
Oct 2, 2018, 10:19:23 AM10/2/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d4fc111c2467c6a9d9491807497e13b08b80dc5d" d4fc111c]:
{{{
#!CommitTicketReference repository=""
revision="d4fc111c2467c6a9d9491807497e13b08b80dc5d"
Refs #27795 -- Removed force_bytes() usage in admindocs.

Refs #12892 is probably obsolete.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:29>

Django

unread,
Oct 3, 2018, 4:40:55 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7" efd8a82e]:
{{{
#!CommitTicketReference repository=""
revision="efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7"
Refs #27795 -- Removed force_bytes() usage in MySQL backend.

The mysqlclient cursor attribute `_last_executed` is always stored as
bytes. Decode it.

TextField values are already type str. No need to decode.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:30>

Django

unread,
Oct 3, 2018, 4:43:46 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"a47dd99cc6883fe3e35895e8c5d4bb53996bd184" a47dd99]:
{{{
#!CommitTicketReference repository=""
revision="a47dd99cc6883fe3e35895e8c5d4bb53996bd184"
[2.1.x] Refs #27795 -- Removed force_bytes() usage in MySQL backend.

The mysqlclient cursor attribute `_last_executed` is always stored as
bytes. Decode it.

TextField values are already type str. No need to decode.

Backport of efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:31>

Django

unread,
Oct 3, 2018, 5:14:09 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"bdae19cf6395d6bfee80864d9e87c4aec241eceb" bdae19cf]:
{{{
#!CommitTicketReference repository=""
revision="bdae19cf6395d6bfee80864d9e87c4aec241eceb"
Refs #27795 -- Removed force_bytes() usage in sessions.

SessionBase.decode() is the inverse operation to SessionBase.encode().
As SessionBase.encode() always returns a string, SessionBase.decode()
should always be passed a string argument. Fixed the file backend, which
was the only backend still passing a bytestring.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:32>

Django

unread,
Oct 3, 2018, 5:34:13 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"f3f31b0fc26f772b198c9683a427f2f7fe208c37" f3f31b0]:
{{{
#!CommitTicketReference repository=""
revision="f3f31b0fc26f772b198c9683a427f2f7fe208c37"
[2.1.x] Refs #27795 -- Removed force_bytes() usage in sessions.

SessionBase.decode() is the inverse operation to SessionBase.encode().
As SessionBase.encode() always returns a string, SessionBase.decode()
should always be passed a string argument. Fixed the file backend, which
was the only backend still passing a bytestring.

Backport of bdae19cf6395d6bfee80864d9e87c4aec241eceb from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:33>

Django

unread,
Oct 3, 2018, 9:15:32 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"5045f8af853c29830db5c028ad299663d96af82d" 5045f8af]:
{{{
#!CommitTicketReference repository=""
revision="5045f8af853c29830db5c028ad299663d96af82d"
Revert "[2.1.x] Refs #27795 -- Removed force_bytes() usage in sessions."

This reverts commit f3f31b0fc26f772b198c9683a427f2f7fe208c37.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:35>

Django

unread,
Oct 3, 2018, 9:15:32 AM10/3/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"54eedddb5084fb572516ad4d7266e13e290c3c8d" 54eedddb]:
{{{
#!CommitTicketReference repository=""
revision="54eedddb5084fb572516ad4d7266e13e290c3c8d"
Revert "[2.1.x] Refs #27795 -- Removed force_bytes() usage in MySQL
backend."

This reverts commit a47dd99cc6883fe3e35895e8c5d4bb53996bd184.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:34>

Django

unread,
Oct 5, 2018, 9:27:05 AM10/5/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4ab071f43cbf9b1dd73b7f76996290a4d9de313f" 4ab071f4]:
{{{
#!CommitTicketReference repository=""
revision="4ab071f43cbf9b1dd73b7f76996290a4d9de313f"


Refs #27795 -- Removed force_bytes() usage in

contrib/staticfiles/storage.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:36>

Django

unread,
Oct 8, 2018, 2:47:41 PM10/8/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"2ba588e7736e28626e34fd1b691fd4d5ae6a2cae" 2ba588e7]:
{{{
#!CommitTicketReference repository=""
revision="2ba588e7736e28626e34fd1b691fd4d5ae6a2cae"
Refs #27795 -- Removed force_text() usage in db/models/sql/query.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:37>

Django

unread,
Oct 10, 2018, 2:57:04 PM10/10/18
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"c82893cb8c6b2a4a876965426c5a5bc4590e1583" c82893cb]:
{{{
#!CommitTicketReference repository=""
revision="c82893cb8c6b2a4a876965426c5a5bc4590e1583"
Refs #27795 -- Removed force_bytes() usage from django/utils/http.py.

django.utils.http.urlsafe_base64_encode() now returns a string, not a
bytestring. Since URLs are represented as strings,
urlsafe_base64_encode() should return a string. All uses immediately
decoded the bytestring to a string anyway.

As the inverse operation, urlsafe_base64_decode() accepts a string.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:38>

Django

unread,
May 12, 2019, 4:44:11 AM5/12/19
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* status: assigned => closed
* resolution: => fixed


Comment:

I think this is mostly done now.

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:39>

Django

unread,
Aug 28, 2019, 3:21:21 AM8/28/19
to django-...@googlegroups.com
#27795: Audit force_text invocations
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"1e6b9e29e64fc9f13d4680be141c64d24eb92cc9" 1e6b9e2]:
{{{
#!CommitTicketReference repository=""
revision="1e6b9e29e64fc9f13d4680be141c64d24eb92cc9"
Refs #27795 -- Removed an unnecessary force_bytes() call in uri_to_iri().

The value returned from urllib.parse.quote() is always a string, so can
safely call .encode().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27795#comment:40>

Reply all
Reply to author
Forward
0 new messages