Switch away from text_type shims.

Review Request #11854 — Created Oct. 15, 2021 and updated

Review Board

In the Python 2 to 3 conversion, the name of the binary type was changed
from str to bytes, and the name of the string type was changed from
unicode to str. In addition, there were some other changes such as
the removal of the basestring type. The six library included a bunch
of helpers to ease this transition. Now that we're Python 3+ only on the
master branch, we can get rid of these and just use the builtins.

Ran unit tests.

Switch away from text_type shims.
Description From Last Updated

W504 line break after binary operator


W504 line break after binary operator

Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.


  1. The code looks fine, but I want to discuss where changes like this should land, and an approach for the 5.0 release.

    We'll likely need to maintain 4 and 5 for a while (given how hard it'll be to move customers off of Python 2.7), both merging changes from 4 to 5 and backporting changes from 5 to 4. That'll be easier if we don't drop or convert too much code to Python 3-only.

    So I'm thinking:

    1. We create a release-5.0.x branch, keep it focused on the Django 1.11 port and features we want to land, but avoid too much code churn (like dropping six usage).
    2. We then finish the move with bigger, wider-reaching changes like this on master, targetting 6.0.

    That should be enough of a transition time to get people from 4 to 5, making it safer to backport/merge changes, since we won't need to worry about things like str() doing the wrong thing accidentally.

    What do you think of that plan?