Opened 10 months ago

Last modified 3 months ago

#27753 new Cleanup/optimization

Cleanups when no supported version of Django supports Python 2 anymore

Reported by: Aymeric Augustin Owned by:
Component: Utilities Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Compatibility with Python 2 is currently being removed in master as part of the Django 2.0 development cycle: see #23919.

However third-party apps may want to remain compatible with all supported version of Django and the corresponding versions of Python, which includes Python 2.

To allow this, compatibility functions or modules aren't removed. They're still importable. They're usually just aliases or no-ops. Here's a list of things to deprecate and remove eventually:

  • django.utils.six
  • django.utils.lru_cache
  • django.utils._os.abspathu, upath, npath
  • django.utils.decorators.available_attrs
  • django.utils.encoding.python_2_unicode_compatible
  • django.utils.encoding.smart/force_text
  • django.utils.http.urlquote/urlquote_plus/urlunquote/urlunquote_plus (unmerged commit)
  • django.utils.safestring.SafeBytes
  • One of either django.utils.safestring.SafeString or django.utils.safestring.SafeText
  • django.test.utils.str_prefix()
  • django.utils.encoding.DjangoUnicodeDecodeError
  • django.utils.functional.curry() (in favor of functools.partial()/partialmethod(); see 5b1c389603a353625ae1603ba345147356336afb)

Change History (15)

comment:1 Changed 10 months ago by Simon Charette

Should we revert the removal of eb0b921c29ace8643a5a4cd136c433727c53dead in this case?

comment:2 Changed 10 months ago by Tim Graham

Triage Stage: UnreviewedSomeday/Maybe

Those methods don't work on Python 3 (AttributeError: 'dict' object has no attribute 'iterkeys') so I don't think they have value for the use case described in the ticket description. A third-party app should use six.iterkeys() as the old test did (which uses keys() etc. on Python 3), or am I missing something?

comment:3 Changed 10 months ago by Claude Paroz

The question we discussed on IRC and GitHub with Tim is about deprecating or not deprecating those items.

I would be for a standard deprecation process as I don't see how this is different from any other deprecation. But I'm open to read about use cases which would push for a delayed deprecation process for items related to Python 2.

comment:4 Changed 10 months ago by Tim Graham

Description: modified (diff)

comment:5 Changed 10 months ago by Tim Graham

Description: modified (diff)

comment:6 Changed 10 months ago by Aymeric Augustin

Description: modified (diff)

comment:7 Changed 10 months ago by Claude Paroz

Description: modified (diff)

comment:8 Changed 10 months ago by Claude Paroz

Description: modified (diff)

comment:9 Changed 9 months ago by Luong Dang Hai

Owner: changed from nobody to Luong Dang Hai
Status: newassigned

comment:10 Changed 9 months ago by Tim Graham

Owner: Luong Dang Hai deleted
Status: assignednew

Please don't work on this ticket -- the timetable for these removals isn't decided but it's not for some years. The "Someday/Maybe" "Triage Stage" of the ticket indicates that it's not appropriate to work on right now.

comment:11 Changed 7 months ago by Jon Dufresne

Description: modified (diff)

comment:12 Changed 7 months ago by Tim Graham

Description: modified (diff)

comment:13 Changed 7 months ago by Jon Dufresne

Description: modified (diff)

comment:14 Changed 6 months ago by Tim Graham <timograham@…>

In 0a66aa15:

Refs #27308, #27753 -- Removed obsolete cookie test mixing bytes with str.

Python 3's SimpleCookie treats all values as strings. Passing a bytes
object coerces to the repr value.

comment:15 Changed 3 months ago by Tim Graham

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top