Description

Looks like django.utils.text.force_unicode was removed recently, without providing a backwards-compatible shim. The method had been documented (and I use it at work) -- so imagine my surprise when updating my Django trunk code resulted in a hard breaking of my site.

Apparently django.utils.encoding.force_text is the new thing going forward. I haven't been paying attention to the developments here, so I'm not comfortable writing a patch for something so fundamental to the framework... :-/

However, by design, it doesn't exist on Python 3 because unicode doesn't exist at all on Python 3.

You seem to assume a 100% backwards-compatibility guarantee when moving from Python 2 to Python 3. This isn't possible, because some Python 2 concepts or constructs don't exist in Python 3.

In addition to the Python porting — for instance renaming __unicode__ to __str__ everywhere, there will be some minor changes to Django libraries — for instance, renaming smart_unicode to smart_str.

While we're making good progress on the code, the documentation remains to be written. We'll have to explain such requirements in the documentation before announcing that Python 3 is officially supported.

Sorry I was unclear -- I'm on Python 2 (not Python 3), and the following results in an ImportError on current master:

from django.utils.text import force_unicode

I can confirm django.utils.encoding.force_unicode exists, but for some reason my legacy code is using django.utils.text, not django.utils.encoding. Looks like I was importing it from an incorrect place here, and it was working only by chance (django.utils.text imported force_unicode itself, putting it in the module-level namespace).

So it seems like this is NOT a problem for people who have imported force_unicode from the correct place. :-) I'll close it -- sorry for the noise!

You know, I'm looking through some third-party libraries, and a fair number of them have from django.utils.text instead of from django.utils.encoding when importing force_unicode. It might be worth adding a from django.utils.encoding import force_unicode to the top of django/utils/text.py so that it doesn't break.